How to Use ChatGPT and PlantUML to Simplify UML Diagram Creation
Leveraging AI and PlantUML to Simplify and Enhance Diagramming for Developers
- Jay McBride
- 5 min read
Introduction:
Creating UML diagrams can often feel like a tedious, time-consuming process. Whether you’re brainstorming a new app idea, mapping system architecture, or working through workflows, diagrams play a critical role in turning concepts into actionable designs.
Enter ChatGPT and PlantUML—a pairing that can transform text-based inputs into professional-grade diagrams. While ChatGPT doesn’t generate visuals directly, it can output diagram-ready code, which you can refine and visualize using tools like Diagrams.net or Miro.
In this guide, we’ll demonstrate how to:
Use ChatGPT and PlantUML to create use case, class, and sequence diagrams for a food journal app.
Adjust use case diagrams for better layout in visualization tools.
Improve ChatGPT’s understanding of PlantUML by leveraging the official reference guide.
Understand the risks of relying solely on AI for diagram creation.
By the end, you’ll be equipped to efficiently produce professional diagrams with clear workflows and relationships.
Why Use ChatGPT and PlantUML?
ChatGPT provides a quick and versatile way to generate the foundation of your UML diagrams. Pairing it with PlantUML unlocks the ability to create detailed visual representations from simple text. Together, they streamline the diagramming process for:
Use case modeling.
Class diagrams for system structure.
Sequence diagrams for workflows.
With tools like Diagrams.net and Miro, you can visualize these outputs with minimal effort, making them ideal for team discussions or client presentations.
Step 1: Generating Use Cases for the Food Journal App
Let’s say you’re designing a food journal app that allows users to log meals, track nutrition, and set goals. Start by prompting ChatGPT to list common use cases.
Prompt Example:
Generate a list of use cases for a food journal app where users log meals, track nutrition, and share progress.
ChatGPT’s output might include:
Register an account.
Log meals with nutritional details.
Set dietary goals.
Track daily calorie intake.
View meal history.
Generate weekly nutrition reports.
Share progress with a nutritionist.
Now, ask ChatGPT to convert these into a PlantUML use case diagram.
Step 2: Creating a Vertical Use Case Diagram with PlantUML
A horizontal layout can become unwieldy, especially in tools like Diagrams.net. To adjust the use case diagram to a vertical layout, you can group use cases by roles and rearrange their order.
Prompt Example:
Convert these use cases into a PlantUML use case diagram with a vertical layout.
Updated PlantUML Code:
@startuml
left to right direction
actor "User" as U
actor "Nutritionist" as N
usecase "Register Account" as UC1
usecase "Log Meals" as UC2
usecase "Set Dietary Goals" as UC3
usecase "Track Nutrition" as UC4
usecase "View Meal History" as UC5
usecase "Generate Nutrition Report" as UC6
usecase "Share Progress" as UC7
U --> UC1
U --> UC2
U --> UC3
U --> UC4
U --> UC5
U --> UC6
U --> UC7
N --> UC6 : "Review Report"
@enduml
Key Changes:
The
left to right direction
directive arranges the diagram vertically.Grouping related use cases under specific actors improves clarity.
Visualization:
Paste the updated code into Diagrams.net under
Arrange > Insert > Advanced > PlantUML
.Alternatively, use Miro with the PlantUML plugin for a clean vertical layout.
Step 3: Building a Detailed Class Diagram
A class diagram is essential for structuring your app’s entities. Let’s define key components for the food journal app.
Prompt Example:
Create a PlantUML class diagram for a food journal app with classes for User, Meal, and NutritionReport.
Generated PlantUML Code:
@startuml
class User {
+userId: UUID
+name: String
+email: String
+register(): void
+setGoals(): void
}
class Meal {
+mealId: UUID
+date: Date
+calories: Float
+addFoodItem(item: FoodItem): void
+calculateNutrition(): Nutrition
}
class FoodItem {
+itemId: UUID
+name: String
+calories: Float
+proteins: Float
+fats: Float
+carbohydrates: Float
}
class NutritionReport {
+reportId: UUID
+startDate: Date
+endDate: Date
+generate(): void
}
User "1" --> "*" Meal : logs
Meal "1" --> "*" FoodItem : contains
User "1" --> "*" NutritionReport : generates
@enduml
What This Diagram Shows:
User logs multiple meals, each containing food items.
Meal aggregates food item data into nutritional values.
NutritionReport summarizes activity over time.
Step 4: Enhancing ChatGPT’s Understanding of PlantUML
ChatGPT’s default understanding of PlantUML is solid but limited. To improve its outputs:
Download the PlantUML Reference Guide: Access the official guide from PlantUML’s website.
Re-upload the Guide into ChatGPT: Use ChatGPT’s upload feature to share the guide.
Ask ChatGPT to Study and Commit the Guide to Memory: Prompt ChatGPT to learn from the reference guide and retain the knowledge for future use.
Prompt Example:
Study the attached PlantUML reference guide, commit it to memory, and use this knowledge to refine your responses.
This enhances ChatGPT’s ability to generate precise and advanced diagrams, incorporating features such as grouping, formatting, and advanced relationships.
Risks of Relying Solely on AI for Diagramming
While ChatGPT and PlantUML streamline diagramming, there are risks:
Incomplete Outputs: AI might miss critical relationships or attributes. Always validate outputs against project requirements.
Over-reliance: Relying solely on generated diagrams can introduce errors if diagrams aren’t cross-checked with stakeholders or documentation.
Editing Challenges: Some diagrams may require significant manual adjustments, especially for complex systems.
Conclusion: Integrating AI Diagramming into Your Workflow
This approach isn’t just a time-saver—it’s a game-changer for collaborative workflows. Whether you’re working solo or within a team, using ChatGPT with PlantUML lets you quickly iterate on ideas and turn them into actionable designs.
For teams, the ability to generate and refine diagrams in real time supports collaborative planning sessions and ensures everyone is on the same page. Visual tools like Diagrams.net and Miro further enhance teamwork by allowing live edits and annotations.
By combining AI-driven suggestions with manual validation and refinement, you achieve the perfect balance of efficiency and accuracy, keeping your project organized and visually clear.
Have you tried this method? Share your experience or tips in the comments. If you found this guide helpful, don’t forget to share, subscribe, and check out my other articles for more actionable insights!