sequence_diagram

block

A page-level block drawing a runtime interaction: participants rank left-to-right, messages flow top-to-bottom in declaration order.

A sequence_diagram draws a runtime interaction coordinate-free: participants rank left-to-right and messages top-to-bottom in declaration order, lifelines extend past the last message, and the height follows the content (only width is declared). It is a page-level block, not a diagram shape.

Participants, messages, notes

A participant's kind picks the head: :box (default), :actor (stick figure), :external (dashed box); link makes it clickable. A message's kind picks the arrow: :sync (solid line, filled head, default), :async (solid, open head), :reply (dashed, open head); the same from and to renders a self-message loop. A note is a margin annotation drawn at the row of the message named by at.

sequence_diagram {
  width = 720

  participant "customer" { name = "Customer"        kind = :actor }
  participant "web"      { name = "Web App" }
  participant "api"      { name = "API Application" }
  participant "stripe"   { name = "Stripe"          kind = :external }

  message "m1" { from = "customer" to = "web"    text = "Submit payment form" }
  message "m2" { from = "web"      to = "api"    text = "POST /orders" }
  message "m3" { from = "api"      to = "stripe" text = "Capture charge" }
  message "m4" { from = "stripe"   to = "api"    text = "charge id"  kind = :reply }
  message "m5" { from = "api"      to = "api"    text = "persist order" }
  message "m6" { from = "api"      to = "web"    text = "201 Created" kind = :reply }
  note    "n1" { at = "m3"  text = "Retries reuse the idempotency key." }
}

Like every @children slot, the participants / messages lists accept computed splices, so a repeated scenario model can generate its figure. See data views.

Related

- diagram

- flowchart shapes

- state_diagram