sequenceDiagramv0.9.4

シーケンスとは?

アクター間・システム間のメッセージを時系列で。

sequenceDiagramUserAPIDBGET /meSELECT…row200 OK
使いどころ

Use a シーケンス when…

01

API request/response timelines

02

Authentication and OAuth flows

03

Multi-actor workflows where order matters

構文の基本

The minimal syntax

Copy this and you have a working シーケンス. Build from here.

sequence.mmd
sequenceDiagram
    autonumber
    participant U as User
    participant W as Web app
    participant A as API
    participant D as Database
    U->>W: Click class="code-str">"Save"
    W->>A: POST /diagrams
    A->>D: INSERT INTO diagrams
    D-->>A: id = 4f2…
    A-->>W: 201 Created
    W-->>U: ✓ Saved
UserAPIDBGET /meSELECT…row200 OK
よく使うパターン

Patterns worth memorizing

autonumber

Add `autonumber` at the top — every arrow gets a step number, perfect for RFCs.

Notes

`Note over A,B: text` spans multiple actors and is great for assumption callouts.

loop / alt / opt

Use control blocks for retries, branches, and optional steps without leaving the diagram.

ハマりどころ

The things that will trip you up

Mermaid silently ignores misspellings — these are the failures we see most.

  1. 01

    Solid `->>` is synchronous; dashed `-->>` is the response — mixing them up reads as a different protocol.

  2. 02

    Participants render in declaration order. If you want a specific order, declare them up front.

  3. 03

    Long messages overflow — break them with `<br/>` inside the label.