---
title: "Flow diagrams"
description: "Draw boxes and arrows that build step by step."
---

> Documentation Index
> Fetch the complete documentation index at: https://sandrinodm.github.io/deckster/llms.txt
> Use this file to discover all available pages before exploring further.

# Flow diagrams

`<Flow>` draws boxes and arrows: an architecture, a request path, a pipeline. This page shows you how to place the nodes, connect and group them, mark the nodes that matter with a card, make the diagram build one step at a time as you explain it, and stay inside the limits `deck lint` checks. Every prop is on [the diagram reference](https://sandrinodm.github.io/deckster/reference/diagrams/); in the terminal, `deck diagrams` prints the components, node kinds, edge options, cards and animation parts with an example each, and `deck diagrams --json` gives an agent the same as data.

For alignment, sizing, and styling, see [diagram design controls](https://sandrinodm.github.io/deckster/data-and-diagrams/diagram-design/).

## Place the nodes

Put a `<Flow>` in the `diagram` layout, under a title that states what it shows, with an optional `<Aside>` for what to notice. Its `title` prop is its accessible name; the build fails without one.

Give every node a grid cell with `col` and `row`, counted from 1. `colSpan` and `rowSpan` widen a node across cells, and `cols` and `rows` on the `<Flow>` set the least size of the grid. The diagram scales to its region and the text stays at the brand's sizes.

```mdx
<Flow title="Checkout request path">
  <Node id="web" kind="client" title="Web app" col={1} row={1} />
  <Node id="api" kind="service" title="Orders API" col={2} row={1} />
  <Node id="db" kind="database" title="Orders DB" col={3} row={1} />
  <Edge from="web" to="api" label="HTTPS" />
  <Edge from="api" to="db" label="SQL" />
</Flow>
```

Or leave every cell out and the kit lays the nodes out automatically with ELK: `layout` picks `layered` (the default), `tree`, `force` or `radial`, and `direction` picks `right` (the default), `down`, `left` or `up`. Cells are the reliable choice when an agent writes the diagram; automatic layout suits a map whose shape follows from its edges:

[Live slide: "Nine services, five layers deep, and not one call goes back up", slide 6 of the diagrams-demo deck](https://sandrinodm.github.io/deckster/decks/diagrams-demo/#/service-map)

`decks/diagrams-demo/slides/service-map.mdx`:

```mdx
---
layout: diagram
title: Nine services, five layers deep, and not one call goes back up
eyebrow: Automatic layout
budget: 1m
---

<Flow title="The Parcelwise service map, laid out automatically" direction="right">
  <Node id="web" kind="mobile" title="Courier app" />
  <Node id="gateway" kind="gateway" title="Gateway" />
  <Node id="orders" kind="service" title="Orders" />
  <Node id="routing" kind="service" title="Routing" />
  <Node id="pricing" kind="function" title="Pricing" />
  <Node id="tracking" kind="service" title="Tracking" />
  <Node id="ordersdb" kind="database" title="Orders DB" />
  <Node id="geo" kind="database" title="Geo index" />
  <Node id="maps" kind="external" title="Maps API" />
  <Edge from="web" to="gateway" />
  <Edge from="gateway" to="orders" />
  <Edge from="gateway" to="tracking" />
  <Edge from="orders" to="pricing" />
  <Edge from="orders" to="ordersdb" />
  <Edge from="tracking" to="routing" />
  <Edge from="routing" to="geo" />
  <Edge from="routing" to="maps" />
</Flow>

<Notes>
Nobody placed these boxes: the layout engine sorted them into tiers from the edges alone. Read it left to right: clients, the gateway, services, then the stores and outside APIs they lean on.
</Notes>
```

Cells are all or nothing. A `<Flow>` that places some nodes and not others fails the build:

```console
$ deck lint launch-review
decks/launch-review/slides/mixed.mdx
  error   schema (mixed): Line 7, column 1: Some nodes have a grid cell and some do not: "api" have none.
          Fix: Give every node `col` and `row`, or remove them all for an automatic layout.

launch-review: 1 error, 0 warnings.
```

## Choose the node kinds

`kind` sets a node's shape and icon. `title` is the name on the node (its `id` when left out), `subtitle` a quieter second line such as `Postgres 16`, and `badge` a small pill on a corner. `icon` overrides the kind's icon with a name from the brand's icon set (`icon="map"`), and `icon="none"` drops it. Several kinds have aliases: `db` is `database`, `lambda` is `function`.

**Node kinds**

| kind | Shape | Icon (lucide / tabler) | Use when |
| --- | --- | --- | --- |
| `service` | card | server / server-2 | An application service or API you run: orders API, auth service, a backend. |
| `database` (also `db`) | cylinder | database / database | A database or any system of record: Postgres, DynamoDB, a ledger. |
| `queue` (also `stream` `bus`) | pipe | list-ordered / list-numbers | A queue, stream or event bus: SQS, Kafka topic, a job queue. |
| `cache` | stack | zap / bolt | An in-memory cache in front of something slower: Redis, Memcached, an edge cache. |
| `storage` (also `bucket`) | card | archive / bucket | Object or file storage: an S3 bucket, a blob store, a file share. |
| `user` (also `person`) | pill | user / user | A person: a customer, an operator, a reviewer. Usually where a journey starts. |
| `client` (also `browser` `web` `app`) | window | app-window / browser | A browser or desktop client: the web app, a single-page app, a CLI on a laptop. |
| `mobile` (also `phone`) | device | smartphone / device-mobile | A mobile app or device. |
| `cloud` | soft | cloud / cloud | A managed platform or the internet as a whole: a CDN, a cloud provider, "the web". |
| `external` (also `third-party`) | dashed | globe / world | A system outside your boundary that you call or that calls you: Stripe, a partner API. |
| `function` (also `lambda` `worker`) | chamfer | lambda / lambda | A serverless function or a worker that runs on demand: Lambda, a cron job. |
| `gateway` (also `proxy`) | hexagon | network / network | An API gateway, reverse proxy or ingress that routes requests inward. |
| `loadbalancer` (also `lb` `load-balancer`) | hexagon | split / arrows-split-2 | A load balancer that spreads traffic over several instances. |
| `agent` | double | bot / robot | An AI agent: the loop that plans, calls tools and talks to a model. |
| `llm` (also `model`) | double | sparkles / sparkles | A language model endpoint: the model an agent or a feature calls. |
| `tool` | card | wrench / tool | A tool an agent can call: search, code execution, a calendar API. |
| `document` (also `file`) | folded | file-text / file-text | A document, file, report or prompt: a PDF, a config file, a knowledge base page. |
| `decision` | diamond | none | A yes/no branch in a process; keep its title to a short question. |
| `node` (also `generic`) | card | none | Anything else: give it an `icon` from the brand set, or children of your own. |

## Connect the nodes

`<Edge from="api" to="db" />` draws an arrow from one node id to another; `to` equal to `from` draws a small loop on the node, such as a retry. `label` wraps after about 18 characters to two lines and is then cut with an ellipsis. Give an edge an `id` to change it with `<State edge="...">`; without one it is `from->to`. The options:

**Edge options**

- `label`: What travels on the edge (HTTPS, SQL, publish); it sits beside the line, never on a node. Wraps after about 18 characters. `<Edge from="api" to="db" label="SQL" />`
- `dashed / async`: An asynchronous, optional or eventual link (events, replication, fire-and-forget). `<Edge from="orders" to="events" async />`
- `lineStyle / strokeWidth`: Vary an ordinary connector's line pattern or width in canvas pixels. `<Edge from="checkout" to="dispatch" lineStyle="dotted" strokeWidth={3} />`
- `route: orthogonal | straight | curved`: orthogonal (the default) routes around nodes with rounded corners; straight runs centre to centre; curved bends gently between ports. `<Edge from="a" to="b" route="curved" />`
- `arrow: end | start | both | none`: Where arrowheads go; `bidirectional` is arrow="both". `<Edge from="agent" to="model" bidirectional />`
- `fromSide / toSide`: Force the side an edge leaves or enters by (top, right, bottom, left) when the router picks another. `<Edge from="api" to="cache" fromSide="top" toSide="bottom" />`
- `self loop`: An edge whose `from` and `to` are the same node draws a small loop on it, such as a retry; a packet from and to that node rides it. `<Edge from="worker" to="worker" label="retry" />`
- `flow`: Continuous traffic along an edge while it is shown: `flow`, `flow={5}` or `flow={{ count, speed, size, role, reverse }}` (see `edgeFlow`). `<Edge from="orders" to="bus" label="publish" flow={{ count: 3 }} />`
- `at / state / id`: Reveal the edge at a step, start it in a state, or name it for `<State edge="...">`. `<Edge id="auth" from="api" to="idp" at={2} />`

## Group the nodes

`<Group label="Production VPC">` draws a labelled container around the nodes inside it, and groups nest:

```mdx
<Group label="Production">
  <Group label="EU region">
    <Node id="eu-api" kind="service" title="API" col={2} row={1} />
    <Node id="eu-db" kind="database" title="Postgres" col={3} row={1} />
  </Group>
  <Group label="US region">
    <Node id="us-api" kind="service" title="API" col={2} row={3} />
    <Node id="us-db" kind="database" title="Postgres" col={3} row={3} />
  </Group>
</Group>
```

A group wraps its nodes, or takes its own `col`, `row`, `colSpan` and `rowSpan`.

## Pick a card

`card` picks the style a node is drawn with, from the cards the brand defines. Five exist in every brand: `default`, `outline`, `solid`, `tint` and `raised`. Each brand draws them in its own way, and a brand may add cards of its own. Use cards to mark the few nodes the slide is about: the one service that matters on `solid`, the systems you call but do not run as `outline`, and every other node on the brand's default.

[Live slide: "Payments is the one service that moves money, so it gets the second review", slide 14 of the diagrams-demo deck](https://sandrinodm.github.io/deckster/decks/diagrams-demo/#/money-path)

`decks/diagrams-demo/slides/money-path.mdx`:

```mdx
---
layout: diagram
title: Payments is the one service that moves money, so it gets the second review
eyebrow: Cards
budget: 1m
surface: inverse
---

<Flow title="The checkout path, with the payments service marked and the outside providers drawn as outlines">
  <Node id="web" kind="client" title="Web app" col={1} row={2} />
  <Node id="checkout" kind="service" title="Checkout" col={2} row={2} />
  <Node id="payments" kind="service" title="Payments" subtitle="Two reviewers" card="solid" col={3} row={2} />
  <Node id="ledger" kind="database" title="Ledger" col={4} row={2} />
  <Node id="fraud" kind="external" title="Fraud score" card="outline" col={3} row={1} />
  <Node id="network" kind="external" title="Card network" card="outline" col={4} row={1} />
  <Node id="email" kind="external" title="Email provider" card="outline" col={3} row={3} />
  <Edge from="web" to="checkout" />
  <Edge from="checkout" to="payments" label="Charge" />
  <Edge from="payments" to="ledger" />
  <Edge from="payments" to="fraud" />
  <Edge from="payments" to="network" />
  <Edge from="checkout" to="email" label="Receipt" async />
</Flow>

<Notes>
Every node here is a service or a store, but only one of them can charge a card twice. That one sits on the solid card, and its pull requests need two reviewers. The three outside providers are outlines: we call them, we do not run them. The cards are standard names, so the slide says the same thing in any brand.
</Notes>
```

Put `card` on a `<Node>` for that node, or on the `<Flow>` for all its nodes. A node takes, in order:

1. its own `card`;
2. its diagram's `card`;
3. the card the brand maps its kind to in [`diagram.kinds`](https://sandrinodm.github.io/deckster/brands/diagram-look-and-cards/#what-a-brand-sets) (four of the five published brands draw `external` nodes as `outline`; Nocturne maps no kind, so the slide above names `outline` itself to draw the providers as outlines in every brand);
4. `default`.

States still win over the card: `highlighted`, `error` and `success` recolour the outline, and `muted` nodes and a `<Focus>` still dim. Use one or two cards on a slide besides the default, each for a reason.

Stay on the five standard names for a deck that should render in any brand. A name the brand does not have does not fail the build: the node falls back to the next card in the order, and `deck lint` warns. Here the same slide, copied into a deck in the Kinetic brand with Payments on Kinetic's own `volt` card, is linted in `default`:

```console
$ deck lint launch-review --brand default
decks/launch-review/slides/money-path.mdx
  warning diagram-card-missing (money-path): The <Flow> "The checkout path, with the payments service marked and the outside providers drawn as outlines" asks for the card "volt" on the node "Payments", which the default brand does not have, so it is drawn with "default".
          Fix: Change the `card` in decks/launch-review/slides/money-path.mdx to one of the standard cards: default, outline, solid, tint, raised, which every brand has.

launch-review: 0 errors, 1 warning in 3 slides (3 steps checked).
```

`deck brand <name>` lists a brand's cards, its own included. How a brand defines them is on [diagram look and cards](https://sandrinodm.github.io/deckster/brands/diagram-look-and-cards/). Cards need `@deckster/cli` 0.4.0 or later. The guide `deck diagrams` prints:

**Cards** (`card="..."`)

A node's card is, in order: its own `card`; its diagram's `card`; the card the brand maps its kind to (`diagram.kinds` in brand.ts); `default`. A name the brand does not have is skipped (the next in that order applies) and the node carries `data-card-missing` with the name asked for; every node carries `data-card` with the card it uses.

| Card | Look, unless the brand restyles it |
| --- | --- |
| `default` | The brand's node: its node fill and border, the icon in a bordered tile. |
| `outline` | No fill, the node border only. |
| `solid` | Filled in the accent, no border, text in the accent foreground. |
| `tint` | The accent at a low opacity with an accent border and a filled icon tile. |
| `raised` | The surface fill, a hairline border and the brand's medium shadow. |

Every brand has the five standard cards and may restyle them or define more of its own (`deck brand <name>` lists them). Stick to the standard names for a deck that should look right in any brand.

- States still win over the card: highlighted, error and success recolor the outline and show the halo, muted and a focus dim the node.
- On `<Layers>` the items follow the stack's `card`; the bands keep the stack's own look unless a `<Layer>` names a card.
- Pick a card for a reason (a role, a group of nodes that belong together), not per node at random: one or two cards on a slide besides the default.

## Build it step by step

Every node, group and edge takes `at`, the step it appears on; an edge also waits for its nodes. Four parts move things on a step:

- `<Packet>`: traffic along an edge, `from` and `to` or a multi-hop `path`. It plays while its `at` step is current, or until `until`; it loops unless `play="once"`, and `reply` sends it back after a pause.
- `<State>`: changes a node or an edge from `at` on (to `until`): `is="highlighted"`, `"error"`, `"success"`, `"muted"` or `"default"`, with an optional `badge` such as `Timeout`.
- `<Focus>`: dims everything but some nodes, and the edges between them, from `at` (to `until`).
- `<Journey>`: a request travelling hop by hop, one hop per step from `at`. `back` brings it back along the path, `focus` dims everything off the path, travelled edges stay lit (`trail`), and `pace="trip"` plays the whole path on one step.

This slide uses packets and state changes: the rules node is in the error state with an "Overflow" badge on step 3 and in the success state on step 4:

*Filmstrip: the steps of "Lint renders every step in a real browser, then measures what it drew", one still per step.* [Open the slide](https://sandrinodm.github.io/deckster/decks/showcase/#/lint-path/0)

```mdx
<Packet path="deck server chromium" at={1} label="slide 7" />
<State node="chromium" at={1} until={2} is="highlighted" />
<Packet path="chromium snapshot rules" at={2} />
<State node="rules" at={3} until={4} is="error" badge="Overflow" />
<Packet path="rules findings" at={3} label="fix" />
<State node="rules" at={4} is="success" />
```

This one is a single line, `<Journey at={1} path="browser cdn gateway orders db" back focus />`, walking a request through a `<Group>` and back while the cache and the queue dim:

*Filmstrip: the steps of "Every checkout crosses five hops before the first byte comes back", one still per step.* [Open the slide](https://sandrinodm.github.io/deckster/decks/diagrams-demo/#/request-journey/0)

When each hop needs its own words, give the journey `<Hop>` children instead of `path`; a hop takes `label`, `reply` and `returning`:

```mdx
<Journey at={1} focus>
  <Hop from="shop" to="hub" label="08:43" />
  <Hop from="hub" to="bike" label="Slot B3" />
  <Hop from="bike" to="door" label="Stop 7 of 9" reply="Signed" />
  <Hop path="door api shop" label="drop.delivered" />
</Journey>
```

Static mode, `deck shot` and every export show each step as a still, with packets frozen partway along and a tail that shows their direction. Steps across the whole slide are on [Builds](https://sandrinodm.github.io/deckster/write-slides/builds/).

## Stay inside the limits

Keep a slide to about 12 nodes, 16 edges, 5 columns and 3 rows. Keep edge labels to a word or two and node titles to about 20 characters: a title wraps to 3 lines at most, and a word too long for its node is broken. `deck lint` checks the drawing on every step with `diagram-overlap` (an error), `diagram-too-dense`, `diagram-label-overlap`, `diagram-unlabeled-edge`, `diagram-edge-overlap`, `diagram-badge-overlap`, `diagram-small-text` and `diagram-long-word`; [Lint rules](https://sandrinodm.github.io/deckster/reference/lint-rules/#diagrams) explains each one.

## Write a flow in TSX

In a TSX slide, import the parts from `@deckster/kit/diagrams` and build the nodes from data. With no grid cells, the automatic layout places them:

[Live slide: "Every deploy passes the same three gates, defined once in code", slide 13 of the diagrams-demo deck](https://sandrinodm.github.io/deckster/decks/diagrams-demo/#/deploy-gates)

`decks/diagrams-demo/slides/deploy-gates.tsx`:

```tsx
import type { ReactNode } from 'react';

import { Notes } from '@deckster/engine';
import { Edge, Flow, Journey, Node, State } from '@deckster/kit/diagrams';

/**
 * Read by the build without running the slide, so it must stay a literal.
 */
export const frontmatter = {
  layout: 'diagram',
  surface: 'inverse',
  title: 'Every deploy passes the same three gates, defined once in code',
  eyebrow: 'Written in TSX',
  budget: '1m',
};

/**
 * The gates between a merge and production, as the pipeline config lists them.
 */
const GATES = [
  { id: 'tests', kind: 'function', title: 'Tests', subtitle: 'Unit and contract' },
  { id: 'canary', kind: 'service', title: 'Canary', subtitle: '5% of traffic, 20 min' },
  { id: 'approval', kind: 'user', title: 'Approval', subtitle: 'On-call engineer' },
] as const;

/**
 * The deploy pipeline drawn from the same list the pipeline runs: a TSX slide maps the data to
 * nodes and edges with no grid cells, so the automatic layout places them (ELK loads for this slide
 * only), and the kind icons resolve at run time.
 */
export default function DeployGates(): ReactNode {
  const ids = ['merge', ...GATES.map((gate) => gate.id), 'production'];
  return (
    <>
      <Flow title="A merge passing tests, a canary and an approval before production">
        <Node id="merge" kind="document" title="Merge" subtitle="main branch" />
        {GATES.map((gate) => (
          <Node
            key={gate.id}
            id={gate.id}
            kind={gate.kind}
            title={gate.title}
            subtitle={gate.subtitle}
          />
        ))}
        <Node id="production" kind="cloud" title="Production" subtitle="3 regions" />
        {ids.slice(1).map((id, index) => (
          <Edge key={id} from={ids[index] ?? 'merge'} to={id} />
        ))}
        <Journey at={1} path={ids} />
        <State node="canary" at={2} until={3} is="highlighted" badge="Watching errors" />
      </Flow>
      <Notes>
        This slide is TSX: the gates come from the same list the pipeline config uses, so the
        picture cannot drift from the pipeline. Walk the release through one gate per click.
      </Notes>
    </>
  );
}
```

`kind` icons resolve from the brand's icon set as in MDX, but `icon` takes an icon component (`import Rocket from '~icons/lucide/rocket'`) or `"none"`: a name string works only in MDX. Props are checked when the slide renders, and an unknown prop or value shows an error naming the closest one in place of the diagram.

## Why the kit draws the diagrams

Diagrams are drawn by the kit, not by an outside tool such as Mermaid. That is what lets a diagram take the brand's colours and type, build by step, get measured by `deck lint` and come out of a PowerPoint export as native shapes. For other diagram forms, see [Sequence, timeline, layers, cycle and tree](https://sandrinodm.github.io/deckster/data-and-diagrams/sequence-timeline-layers-cycle-tree/); for a drawing someone made, see [SVG](https://sandrinodm.github.io/deckster/data-and-diagrams/svg/).

Source: https://sandrinodm.github.io/deckster/data-and-diagrams/flow-diagrams/index.mdx
