Skip to content

Your first figure

SHEET
A4
REV
flowfig 0.8.4
SOURCE
README.md
DATE
2026-10-06

Save this spec as first.json. The spec has 3 boxes, 2 edges and 1 step.

{
"layout": {
"children": [
{ "id": "browser", "label": "Browser" },
{ "id": "api", "label": "API" },
{ "id": "db", "label": "Database", "shape": "store" }
]
},
"edges": [
{ "from": "browser", "to": "api", "label": "GET /user" },
{ "from": "api", "to": "db", "label": "read the user" }
],
"steps": [
{
"label": "Load a user",
"flow": [
{ "edges": "browser->api", "say": "The browser asks the API for the user." },
{ "edges": "api->db", "say": "The API reads the row." },
{ "edges": { "edge": "api->db", "back": true }, "say": "The row comes back." },
{ "edges": { "edge": "browser->api", "back": true }, "say": "The API sends the user as JSON." }
]
}
]
}

Render the spec:

$ npx flowfig first.json
0 errors, 0 warnings
figure: 3 boxes, 0 groups, 2 edges, 1 step, 4 messages
browser -> api: GET /user
api -> db: read the user
step "Load a user": 4 hops
first.svg — 9.7 kB

The render prints the check result, the counts, one line per edge and one line per step. Read these lines to check the figure without a second command. If a box or an edge has a source or a via, the render also prints the verify counts. --no-verify skips them.

The command writes first.svg:

A browser loads a user through an API from a database

The SVG has no script and fetches no font. GitHub shows the SVG in a README, a PR or an issue. The SVG follows the light or dark color scheme of the reader.

Each SVG from the CLI carries its own spec. These commands made the rail-only figure from docs/checkout.svg:

npx flowfig --spec docs/checkout.svg > checkout.json # print the spec in the SVG
# edit checkout.json: set "props.rail" to "only"
npx flowfig checkout.json docs/checkout-rail-only.svg
npx flowfig verify docs/checkout.svg # check each source and each edge against the code
npx flowfig diff old.svg docs/checkout.svg # list what changed in the spec