Event modelling (Mermaid)

Event modelling lays a system out along time: commands in, events recorded, read models projected. A sequence diagram captures the essential ordering without the full workshop board.


#What this example shows

  • Commands in the imperative and events in the past tense.

  • A projection step, which is where read models come from.

  • A read model queried separately from the command path.


#A worked example

Open it, edit it, or copy the source below.

Event modelling (Mermaid)

The source, which you can paste into a new diagram and edit:

sequenceDiagram
  autonumber
  actor C as Customer
  participant UI as Checkout
  participant CMD as Order service
  participant ES as Event store
  participant RM as Order history
  participant NOT as Notifications

  C->>UI: Place order
  UI->>CMD: PlaceOrder command
  CMD->>ES: OrderPlaced event
  ES-->>RM: project
  ES-->>NOT: project
  NOT-->>C: Confirmation email

  C->>UI: Cancel order
  UI->>CMD: CancelOrder command
  CMD->>ES: OrderCancelled event
  ES-->>RM: project

  C->>RM: View order history
  RM-->>C: Orders shown

  Note over ES,RM: Read models are projections.<br/>They hold no truth of their own.

#Making it your own

  • Events are facts in the past tense: OrderPlaced, not PlaceOrder.

  • A read model with no event feeding it is a design gap.

  • For the full workshop version with swimlanes, use Excalidraw.



Copy it. Change one line. See what happens.