Schematex

UML Sequence Diagram

About sequence diagrams

A sequence diagram shows how participants exchange messages over time: lifelines run top→bottom, messages run left→right between them, and the vertical axis is order. Defined by UML 2.5.1 §17 (Interactions), it's the diagram engineers reach for to pin down an API call flow, an auth handshake, or a distributed protocol — who calls whom, in what order, and what comes back.

Schematex implements the full UML notation, and for generation it also accepts the Mermaid sequenceDiagram dialect — paste Mermaid in unchanged and it renders. Under the sequenceDiagram header the arrows take Mermaid meaning (->> synchronous call, -->> reply, -) async); under the native sequence "Title" header the long-standing Schematex meaning is kept (->> = async). Where most tools stop at the common subset (alt/opt/loop/par), Schematex carries all twelve combined-fragment operators and ref interaction-use frames, because those are the parts professionals reach for when an interaction gets real. Distinct from usecase (system scope, not message order), state (one object's modes, not inter-object messages), and bpmn (organisational process, not a call sequence).

sequence·§
↘ preview
100%
Sequence Diagram — Login flow 4 participants, 8 messages, 1 combined fragments. Login flow User Web App Auth DB alt [credentials valid] [invalid] submit(credentials) verify(credentials) SELECT user row token 200 OK 401 error session cookie set
UTF-8 · LF · 21 lines · 432 chars✓ parsed·5.6 ms·7.9 KB SVG

1. Your first diagram

Every document starts with the sequence keyword and an optional "title". Participants don't need to be declared — the first time you mention one in a message, it becomes a lifeline:

sequence
  Alice -> Bob : Authentication Request
  Bob --> Alice : Authentication Response

Lifelines appear left-to-right in first-use order. -> is a synchronous call (solid line, filled arrowhead); --> is a reply (dashed line, open arrowhead). Text after : is the message label.


2. Participants

Declare a participant explicitly to set its kind, give it an alias, or fix its order:

sequence
  actor User
  participant Web as "Web App"
  boundary LoginUI
  control Auth
  entity Account
  database DB
  collections Sessions
  queue Events
KindRendered as
participant (default)rounded classifier box
actorstick figure
boundary / control / entitythe Jacobson robustness icons (⊢◯ / ◯ with arrow / ◯ with underline)
databasecylinder
collections / queuebox with the kind as a «stereotype»
  • as "Label" sets the display name (quotes optional; 「…」 CJK quotes accepted).
  • A custom stereotype goes in guillemets or ASCII angle brackets after the declaration — it overrides the default label: actor Printer «system», participant Bus as "Event Bus" <<service>>.

3. Messages

The arrow token chooses the UML semantics:

DSLMeaningRendering
A -> Bsynchronous callsolid line, filled arrowhead
A ->> Basynchronous signalsolid line, open arrowhead
A --> Breply / returndashed line, open arrowhead
A -x Blost messageline ending at a filled circle
o-> Bfound messageline starting from a filled circle
A -> Aself messagebent loop back to the same lifeline

Whitespace around arrows is optional (A->B works), and labels are free text — including a return value, e.g. aHotel -> aHotel : available(roomId, date): isRoom.


4. Activations (execution specifications)

The thin bar on a lifeline shows it is active. Open and close it with explicit statements, or with + / - suffixes on the messages themselves:

sequence
  participant Client
  participant Server
  Client ->+ Server : request()
  Server ->> Server : validate()
  Server -->- Client : response

+ after the arrow activates the receiver on arrival; - deactivates the sender after the message is sent. The explicit form is activate X / deactivate X. Overlapping bars on one lifeline nest with a horizontal offset.


5. Object creation & destruction

sequence
  participant Factory
  Factory -> *Worker : «create»
  Factory -> Worker : work()
  destroy Worker

Prefix the receiver with * to make the message instantiate it — the new lifeline's head is drawn at the arrival row, not at the top. destroy X ends a lifeline with a ✕ and stops its time axis.


6. Combined fragments

A combined fragment is a labelled frame around a region. Schematex implements the full UML InteractionOperatorKind set:

OperatorMeaningOperands
altalternatives (if/else-if/else)else, each guarded
optruns iff the guard holdsone, guarded
looprepeatone; guard may be (min,max)
parconcurrent operandsand
breakexceptional exitone, guarded
criticalatomic / no interleavingone
seq / strictweak / strict sequencingand
neginvalid traces (rendered tinted)one
ignore / considermessage-set filter {m1, m2}one
assertthe only valid continuationone
sequence
  actor User
  participant API
  User -> API : GET /resource
  alt [authorized]
    API --> User : 200 + body
  else [forbidden]
    API --> User : 403
  end

Guards go in [brackets] after the operator (and after else). Fragments nest, and inner frames inset automatically so they sit cleanly inside their parent.


7. Interaction use (ref)

Reference another interaction instead of inlining it — the way UML keeps large diagrams composable:

sequence
  participant A
  participant B
  ref over A, B : Establish session
  A -> B : poll()

ref over <lifelines> : Name draws a framed box across the named lifelines. Most tools omit this; it's how real systems decompose long flows.


8. Notes, dividers, invariants, numbering

sequence
  autonumber 1 1
  actor Shopper
  participant Cart
  == Phase 1: review ==
  Shopper -> Cart : view items
  note over Cart : cart persisted in Redis
  state Cart : ready
  • note over A / note over A, B / note left of A / note right of A — folded-corner annotations.
  • == text == — a full-width section divider.
  • state X : text — a state-invariant capsule on a lifeline.
  • autonumber [start] [step] — prefix every message with an incrementing number.

9. Grammar (EBNF)

diagram      = "sequence" [ string ] NEWLINE statement*
statement    = participant | message | activation | note
             | fragment | ref | divider | invariant | destroy | autonumber

participant  = kind IDENT ("as" label)? stereotype?
kind         = "participant" | "actor" | "boundary" | "control"
             | "entity" | "database" | "collections" | "queue"
stereotype   = "«" TEXT "»" | "<<" TEXT ">>"

message      = IDENT? act? arrow act? ("*")? IDENT? (":" TEXT)?
arrow        = "->" | "->>" | "-->" | "-x" | "o->"
act          = "+" | "-"
activation   = ("activate" | "deactivate") IDENT

fragment     = ("alt"|"opt"|"loop"|"par"|"break"|"critical"|"seq"
               |"strict"|"neg"|"ignore"|"consider"|"assert") guard? NEWLINE
                 statement* (("else"|"and") guard? NEWLINE statement*)* "end"
guard        = "[" TEXT "]" | "(" NUMBER ("," NUMBER)? ")"
ref          = "ref" "over" IDENT ("," IDENT)* ":" TEXT
note         = "note" ("over"|"left of"|"right of") IDENT ("," IDENT)? ":" TEXT
divider      = "==" TEXT "=="
invariant    = "state" IDENT ":" TEXT
destroy      = "destroy" IDENT
autonumber   = "autonumber" NUMBER? NUMBER?

10. Standard compliance

Schematex follows the OMG UML 2.5.1 §17 (Interactions) notation: synchronous (filled) vs. asynchronous (open) vs. reply (dashed) arrowheads, found/lost message endpoints, execution-specification bars, all twelve combined-fragment operators with guarded operands, ref interaction-use frames, and the Jacobson analysis-class icons for boundary/control/entity. Gates, coregion, and time/duration constraints are out of scope for v0.1 (they need new layout primitives) and tracked for a later release. See docs/reference/33-SEQUENCE-STANDARD.md for the full specification.


Ready-to-use scenarios from the examples gallery:

sequence·§ OMG UML 2.5.1 §17 (Interactions)
Sequence Diagram — Login flow 4 participants, 8 messages, 1 combined fragments. Login flow User Web App Auth DB alt [credentials valid] [invalid] submit(credentials) verify(credentials) SELECT user row token 200 OK 401 error session cookie set
Login flow with an alt fragment
An authentication handshake across an actor, a Jacobson control object, and a database lifeline — synchronous calls open activation bars, a dashed reply returns the row, and an alt combined fragment splits the valid/invalid branches. A note records the session-cookie side effect.
business & operations
sequence·§ OMG UML 2.5.1 §17 (Interactions)
Sequence Diagram — OAuth 2.0 Authorization Code 5 participants, 16 messages, 1 combined fragments. OAuth 2.0 Authorization Code User Browser Web App Auth Server User Store alt [token exchange ok] [exchange failed] click "Sign in" GET /login 302 → Auth Server GET /authorize consent screen approve 302 + auth code GET /callback?code POST /token (code) load user profile access + refresh token Set-Cookie: session signed in 401 Unauthorized retry
OAuth 2.0 authorization-code login
The canonical browser-based sign-in handshake as a UML sequence diagram — redirect to the auth server, user consent, code-for-token exchange, and an alt fragment for the success vs. failure branch, with activation bars tracking who is busy at each step.
software & it
sequence·§ OMG UML 2.5.1 §17 (Interactions)
Sequence Diagram 2 participants, 3 messages, 0 combined fragments. Factory Worker «create» external trigger fire-and-forget
Object lifecycle — create, found, lost, destroy
The four UML interaction lifecycle markers in one short diagram — a create message draws its arrow to the new participant's box, a found message starts from a filled circle, a lost message ends at one, and destroy terminates a lifeline with an ✕.
education
sequence·§ OMG UML 2.5.1 §17 (Interactions)
Sequence Diagram — Order processing (saga) 6 participants, 13 messages, 2 combined fragments. Order processing (saga) Customer API Gateway Order Service Payment Service Inventory Service «queue» Event Bus par alt [payment captured && stock reserved] [payment failed] ref Validate cart & price POST /orders createOrder() charge(card) reserve(items) paid reserved OrderConfirmed 201 Created confirmation release(items) OrderCancelled 402 Payment Required declined
Microservices order saga
A distributed order-processing saga showing the parts of UML sequence notation that generic tools omit — a ref interaction-use frame, a par fragment for concurrent service calls, asynchronous event-bus messages, and an alt fragment with a compensating rollback on payment failure.
software & it

Found this useful?

Schematex is free, fully open source, and zero-dependency. A star helps other developers discover it.