Chalkline / Guides / Sequence diagram tutorial

Sequence diagrams, explained with examples

A sequence diagram shows who talks to whom, in what order. It is the clearest way to explain an API call, a login or a payment. Here is the notation and how to draw one quickly.

Updated 7 November 2026 · 2 minute read

What a sequence diagram is

A sequence diagram puts each participant (a person, a browser, a server, a database) in a column. A dashed line runs down from each one: its lifeline. Messages are arrows between lifelines, and time flows from top to bottom. Read it like a comic strip: first this, then that.

The notation

ElementDrawn asMeans
ParticipantA box at the topSomeone or something taking part
LifelineA dashed line down from the boxThe participant over time
MessageA solid arrowA request or a call
ReplyA dashed arrowAn answer coming back
NoteA small sticky noteExtra information
AlternativeA frame labelled alt and elseTwo possible paths

Example: logging in

A login request with a wrong password pathA login request with a wrong password pathalt: Password correctBrowserAPIDatabasePOST /loginFind user by emailUser row200 OK and a token401 UnauthorizedPasswords are stored hashed[Wrong password]
A login request with a wrong password pathOpen this example in Chalkline →

The text behind it:

sequenceDiagram
  participant B as Browser
  participant A as API
  participant D as Database
  B->>A: POST /login
  A->>D: Find user by email
  D-->>A: User row
  alt Password correct
    A-->>B: 200 OK and a token
  else Wrong password
    A-->>B: 401 Unauthorized
  end
  Note over A,D: Passwords are stored hashed

How to draw one in five steps

  1. List the participants from left to right in the order they first act. The one who starts goes on the left.
  2. Write the happy path first: every message when everything works.
  3. Add replies as dashed arrows, only where the answer matters.
  4. Add alternatives with alt and else for errors and branches.
  5. Add notes sparingly for facts that are not messages, such as "cached for 5 minutes".

Arrow types in text

A->>B: message           solid arrow
A-->>B: reply            dashed arrow
A->B: message            solid line, open end
A-->B: reply             dashed line, open end
Note over A,B: text      a note across two lifelines
Note right of A: text    a note beside one lifeline
Draw your own sequence diagramOpen Diagram as text, pick Sequence, and type messages
Open the example

Tips

  • Keep to five or six participants. More than that usually means two diagrams.
  • Name messages after what they do ("Charge card"), not after code ("processPaymentV2").
  • Show only the replies people need to understand the flow.
  • For long flows, split by stage: login, browse, checkout.

Drawing sequence diagrams for free

In Chalkline, open Diagram as text → Sequence, type the messages and press Apply. Switch between hand drawn and clean, export to SVG, PDF or PowerPoint, or share a link. If you have the code but not the diagram, see Python code to flowchart. For the other common UML diagram, see UML class diagram examples.