A sequence diagram shows how different parts of a system exchange messages over time, read top to bottom as a timeline. To draw a good one: list the participants first (aim for four or fewer), order messages chronologically from top to bottom, use solid arrows for requests and dashed arrows for responses, and split any scenario that grows past a screenful.
This guide explains the notation, the rules that keep sequence diagrams readable, mistakes to avoid, and how an AI sequence diagram generator produces them from a plain-language description.
Sequence diagrams answer the question "who talks to whom, in what order, with what messages?" They are the standard tool for:
Unlike a flowchart, which focuses on decisions and branches, a sequence diagram makes the order and responsibility of each message explicit. When your main question is "which service sends what, and when", sequence is the right notation — see flowchart vs sequence diagram for choosing between them.
A sequence diagram has a small vocabulary. Master these five elements and you can read almost any diagram:
| Element | What it looks like | Meaning |
|---|---|---|
| Participant | Box at the top of a column | A system, service or person ("Frontend", "Payment API") |
| Lifeline | Dashed vertical line | The participant's existence over time |
| Message (request) | Solid arrow, left to right | A call or command sent now |
| Response | Dashed arrow, right to left | A reply returning later |
| Activation bar | Narrow rectangle on a lifeline | The period a participant is processing |
Two optional extras cover most advanced needs: self-messages (arrow looping back to the same lifeline, for internal calls) and alt/opt frames (a boxed region showing branching, like if/else). Numbers on messages — Mermaid's autonumber — are worth enabling whenever you reference steps in prose.
"Frontend", "Order API" and "Database" describe responsibility precisely. Human actors are the exception — an end user entering the flow is conventionally an actor figure. If you catch yourself naming a participant "Service 1", you haven't decided what it does yet.
Readability collapses fast as columns multiply: each new participant adds a horizontal band every message must cross. When more than four systems are involved, either split the scenario or collapse internal detail into one participant and expand it in a separate diagram.
The diagram reads top-to-bottom as a clock. Messages that happen first go at the top. Likewise, put the most chatty pair of participants next to each other: shorter arrows, fewer crossings, calmer diagram.
Solid arrow for the call, dashed arrow for the return. When every line looks the same, readers can't tell an action from its acknowledgment. If a call has no meaningful response (fire-and-forget event), omit the return — silence communicates "no reply expected".
"Password reset — success" and "password reset — expired token" are two diagrams, or two clearly framed alt branches — not two interleaved stories in one chart. Mixing scenarios is the fastest way to make a sequence diagram unreadable.
With autonumber-style numbering, "on step 3 the order service validates the cart" becomes checkable at a glance. Numbering costs nothing and saves every future reader a slow recount.
Here is a clean order-placement flow: four participants, numbered messages, solid requests and dashed responses:
sequenceDiagram
autonumber
actor U as User
participant FE as Frontend
participant API as Order API
participant DB as Database
U->>FE: Click "Place order"
FE->>API: POST /orders
API->>DB: Insert order row
DB-->>API: Order saved
API-->>FE: 201 Created
FE-->>U: Show success page
Note the properties that make it readable: the busiest pair (Frontend, Order API) sits adjacent, requests and responses are visually distinct, and every step is numbered for reference.
Hand-writing the syntax is learnable but slow — every message is a line of precise notation. The faster path is describing the exchange in plain language: "the user clicks place order, the frontend calls the order API, the API saves the order in the database and returns created, the frontend shows a success page". An AI sequence diagram generator turns that sentence into the diagram above, rendering live as the code streams in.
Refinements stay conversational — "number the messages", "rename Order API to Checkout Service", "add a payment service between API and database" — and the code remains standard Mermaid: editable by hand, renderable in GitHub and Notion, exportable to watermark-free PNG/SVG for design docs and reviews.
Solid arrows are requests or commands (something happens now); dashed arrows are responses or returns (a reply to an earlier request). Keeping the distinction consistent is what makes a sequence diagram traceable.
Four or fewer keeps it readable on a normal screen. More than that, split the scenario or collapse internal systems into a single participant and expand it separately.
Yes. Describe the message flow in plain language and an AI generator produces standard Mermaid sequence code — AI Diagram renders it live in the browser, keeps it conversationally editable, and exports watermark-free PNG/SVG free of charge. If you're new to Mermaid as a whole, the Mermaid primer covers the pros, cons and how AI fits in.
Use a sequence diagram when the story is message order between systems; use a flowchart when the story is branching logic within a process. A checkout flow typically needs both: the flowchart for payment success/failure branches, the sequence diagram for the service call chain — see how to make a flowchart for the other side.