Efficient Diagram Generation: ChatGPT and Mermaid Script for Software Engineering

Making diagrams in software engineering is of utmost importance as it provides a visual representation of complex systems, aiding in understanding, communication, and documentation. Diagrams serve as a common language that bridges the gap between developers, stakeholders, and users, allowing them to grasp the intricacies of software designs and architectures. They help in identifying requirements, capturing design decisions, and organizing components and relationships.

We can easily make these diagrams with ChatGPT and Mermaid‘s help. Mermaid is a simple and flexible text-based diagramming language used for creating various types of diagrams, such as flowcharts, sequence diagrams, Gantt charts, and more. It allows users to define diagrams using a Markdown-like syntax that is easy to read and write.

software engineering

Getting Started

Now, We will create a database of a real-life problem with the help of ChatGPT and will make different software engineerings diagrams like flowcharts, sequence diagrams, and more for the same

Let’s create a database for a site of a restaurant. Let’s ask ChatGPT.

Prompt 1

I want to make an online site for a restaurant. Can you give me what feature I should have at the initial stage? Give me suggestions from the tech point of view

Here is what we got as a response.

Response 1

Now, Let’s make a database for the problem.

Prompt 2

As a developer, I want to create a database for my restaurant site. could you please provide me with the database for the same

This is what we got as a response.


Now, Let’s make the software engineering diagram for the above database. We asked ChatGPT to generate a mermaid script for the above database.

Class Diagram

Prompt 3

I want to create a class diagram for the above database. Could you please generate the mermaid script for the same?

Here is the response that we got from ChatGPT.

class Users {
+user_id : int (PK)
+username : string
+email : string
+password : string
+phone_number : string
+address : string

class MenuItems {
    +item_id : int (PK)
    +name : string
    +description : string
    +price : float
    +category_id : int (FK)

class Categories {
    +category_id : int (PK)
    +name : string

class Orders {
    +order_id : int (PK)
    +user_id : int (FK)
    +order_date : datetime
    +total_amount : float
    +status : string

class OrderItems {
    +order_item_id : int (PK)
    +order_id : int (FK)
    +item_id : int (FK)

Users "1" -- "0..*" Orders : places
MenuItems "1" -- "0..*" OrderItems : includes
Categories "1" -- "0..*" MenuItems : contains

Now, Go to the Mermaid GitHub page and go to the class diagram live editor and paste the above script.

Here is the class diagram of the above database.

Class Diagram

Sequence Diagram


I want to create the sequence diagram for the above database. could you give me the mermaid script for the same

This is the script we got from ChatGPT.

participant User
participant Application
participant Database

User ->> Application: Request menu items
Application ->> Database: Query menu items
Database -->> Application: Return menu items
Application -->> User: Return menu items

User ->> Application: Add item to cart
Application ->> Database: Query item details
Database -->> Application: Return item details
Application ->> Database: Add item to cart
Database -->> Application: Confirm item added

User ->> Application: Place order
Application ->> Database: Create order
Database -->> Application: Return order ID
Application ->> Database: Add order items
Database -->> Application: Confirm order items added
Application ->> Database: Update order status
Database -->> Application: Confirm order placed
Application -->> User: Return order confirmation

User ->> Application: View order details
Application ->> Database: Query order details
Database -->> Application: Return order details
Application -->> User: Return order details

Receive sequence diagram from Mermaid using the above script

Sequence Diagram

Gantt Diagram


I want to create a Gantt chart for the same. Could you give me the mermaid script with respect to the above schema?

dateFormat YYYY-MM-DD
title Restaurant Management System

section Users
User Registration             :done,    des1, 2023-01-01, 7d
User Login                    :done,    des2, after des1, 5d

section Menu Management
Add Menu Item                 :active,  des3, after des2, 4d
Edit Menu Item                :          des4, after des3, 3d
Delete Menu Item              :          des5, after des4, 3d

section Order Management
Place Order                   :          des6, after des5, 4d
View Order History            :          des7, after des6, 3d
Manage Order Status           :          des8, after des7, 3d

section Reporting
Generate Sales Report         :          des9, after des8, 5d
Generate Order Analysis       :          des10, after des9, 5d

Here is the Gantt Chart received for the above mermaid script.

Gantt Chart

Likewise, you can generate any software engineering diagram with the help of ChatGPT and Mermaid script. It may be possible that the output is not matching your expectation. Of course, You can edit the script as you want.


In conclusion, generating software engineering diagrams with the help of ChatGPT and Mermaid script can be a powerful and efficient approach. ChatGPT, powered by its natural language processing capabilities and access to vast amounts of knowledge, can understand and interpret user requests for diagram generation. It can provide suggestions, explanations, and examples to assist in creating the desired diagrams. However, it’s important to note that while ChatGPT can provide valuable guidance, it’s still necessary to validate and refine the generated diagrams. The generated diagrams should be reviewed and adjusted as per specific project requirements and industry best practices.

Overall, the combination of ChatGPT and Mermaid script opens up new possibilities for developers and non-technical users alike, making software engineering diagrams more accessible, efficient, and collaborative.


What is Mermaid script?

Mermaid script is a text-based diagramming language that can be used to create flowcharts, sequence diagrams, Gantt charts, and other types of diagrams.

How can I use ChatGPT and Mermaid Script for making diagrams?

ChatGPT can generate Mermaid script code, but it may require some additional development work to do so. You can use ChatGPT to understand user input and generate natural language responses, and then use this information to generate Mermaid script code that creates a diagram based on the user’s input.

Subscribe to divine.ai for more content.

Leave a Reply

Your email address will not be published. Required fields are marked *