Telling a story
A scenario is an ordered list of steps. Each step sends a packet along your edges, or makes one node do something. A diagram can have as many scenarios as you like, and readers pick one above the canvas.
Everything in one picture. Letters on the edges match the interfaces table underneath.
The product is not cached yet, so the catalogue reads PostgreSQL and fills the cache for the next shopper.
The next request for this product is a hit.
| Key | From → To | Kind | Auth | What travels |
|---|---|---|---|---|
| A | Shopper browser → CDN | http | — | HTTPS |
| B | CDN → API gateway | http | — | — |
| C | API gateway → Keycloak | data | client credentials | signing keys |
| D | API gateway → catalog-service | http | — | /products |
| E | API gateway → cart-service | http | — | /cart |
| F | API gateway → order-service | http | — | /orders |
| G | catalog-service → Redis | data | — | cache |
| H | catalog-service → PostgreSQL | data | — | — |
| I | cart-service → Redis | data | — | — |
| J | order-service → PostgreSQL | data | — | — |
| K | order-service → Stripe | channel | API key | payment intent |
| L | order-service → RabbitMQ | queue | — | order.created |
| M | RabbitMQ → notification-worker | queue | — | — |
Press Play. The packet flies, the step list under the player follows along, and the boxes the story has visited stay lit.
The smallest scenario
Section titled “The smallest scenario”scenarios: load-page: title: Load a page steps: - browser -> api: GET /items - api -> db: { label: SELECT, kind: lookup } - db -> api: rows - api -> browser: 200 OKA scenario needs a title and either steps or phases. Its id (load-page) appears in deep links.
What a scenario can have
Section titled “What a scenario can have”| Field | Meaning |
|---|---|
title |
Required. The button’s label. |
summary |
Markdown: the story in a sentence or two, shown above the diagram. |
steps or phases |
The steps, flat or grouped. See steps and phases. |
view |
The view it plays on. Defaults to the first view. |
mode |
How it opens: flow (default), sequence or story. |
lanes |
The columns of the story view. |
Where scenarios live
Section titled “Where scenarios live”Short ones fit inside diagram.yaml. A long one can live in its own file. Every diagrams/<name>/scenarios/<id>.yaml becomes a scenario with that id, and the file holds the scenario’s fields directly:
title: Device is offlinesummary: The job waits in the queue until the device reconnects.phases: - title: Dispatch steps: - backend -> control-api: enqueue jobDefining the same id in both places is an error.
Three ways to read the same steps
Section titled “Three ways to read the same steps”Every scenario can be shown as packets over the architecture (Flow), as a Sequence diagram, or as a swimlane Story. The player has a button for each, and mode: picks which one a scenario opens in. You write the steps once.
Writing scenarios worth watching
Section titled “Writing scenarios worth watching”- One story per scenario. Show failures as their own scenarios (
payment-declined), not as footnotes to the happy path. Readers learn the most from the failures. - Start with the happy path. Then add the two or three failures that teach something about the design.
- Give every scenario a one-sentence
summary. It is the first thing a reader sees. - Keep it to what a reader can follow, roughly 6 to 15 steps. Group longer ones into two to five phases with plain titles such as “Submit”, “Charge” and “Finish”.
- Label what travels:
POST /orders,order.created,200 OK. Explain why in anote:, not in the label.