Karyo
Documentation/ Reference

Diagram sources

Karyo 2.1.1rendered at build time
On this page

Every figure in the README and under docs/ is rendered from a Mermaid source in this directory, in the Operational Blueprint house style (../style-guide.md). The sources are the truth; the SVGs are generated, checked in and guarded.

NN-name.mmd            source: frontmatter, diagram, `class node role` lines; no colours
NN-name.svg            light render (generated)
NN-name.dark.svg       dark render (generated)
tokens.json            the palette: light/dark token pairs and the roles built from them
theme.json             Mermaid configuration template; {token} placeholders resolve per variant
fonts/                 Liberation Sans (SIL OFL 1.1), embedded only while rendering, for stable text metrics

Author

  1. Copy the closest existing source. Keep one concept per figure and the shapes, line treatment and vocabulary of the style guide.
  2. Give every node a role with class a,b core style lines. Roles are the keys of roles in tokens.json: artifact, core, store, human, constraint, external, boundary, optional, frame. Never write a colour literal, a classDef, a style or linkStyle line, or an %%{init}%% directive; the renderer injects one classDef per role you use, per variant. The only look is frontmatter config.look. An erDiagram takes no roles: its entities draw in the theme's surface, ink and alternating row tokens.
  3. Set config.look: handDrawn in the frontmatter only for the README lead and functional concept figures; the consistency test allows two such sources. Architecture, boundary, deployment and decision-record figures use the clean look.
  4. Quote a label that contains parentheses, a colon or a slash (api["REST /api/v1"]).

Render

cd tests/e2e
npm ci                              # once; pins mermaid and @playwright/test
npx playwright install chromium     # once; the same Chromium the browser tests use
npm run diagrams                    # every source, both variants
npm run diagrams -- 03-service-architecture
npm run diagrams -- --preview /tmp/previews   # also writes PNG previews to look at

The renderer, tests/e2e/scripts/render-diagrams.ts, opens Mermaid in Playwright's Chromium with Liberation Sans embedded as the page's "Arial" face, and gives the browser a fontconfig that prefers the same file for "Arial", because Mermaid also measures some labels in the generic sans-serif, which Chromium resolves to its platform Arial. Text measurement, and therefore layout, then does not depend on the fonts installed on the machine. The first line of every SVG is a provenance comment:

<!-- karyo-diagram source=NN-name.mmd variant=light look=classic source-sha256=... tokens-sha256=... theme-sha256=... font-sha256=... mermaid=11.x.y playwright=1.x.y -->

Renders are byte-identical for the same inputs: handDrawnSeed pins the rough.js sketch, the fonts are pinned in theme.json, and the embedded font pins the metrics. Commit the SVGs with the source.

Check

  • npm run test:helpers in tests/e2e (hermetic, no browser): every source has both renders and their provenance matches the source, palette, theme, font, the applied look, and the versions pinned in tests/e2e/package-lock.json; sources carry no colour literals, classDef, style, linkStyle, or init directives; every role exists; the provenance look stays within the hand-drawn budget; the palette meets WCAG contrast in both variants; every image in the repository's Markdown resolves, has alt text and pairs a dark source; there are no inline ```mermaid fences left - every figure lives in docs/diagrams/; the README keeps to three figures and one screenshot pair; the screenshots match their manifest; and every file under docs/media, other than the screenshot manifest, is shown by a document.
  • The nightly frontend job runs npm run diagrams and git diff --exit-code on this directory, so a source that was edited without re-rendering, or a render edited by hand, fails that night's run.

To prove a guard fails when it should, change a source or a render on purpose and run the check. Commit your work in progress first. git checkout -- <path> cannot restore an untracked file, and it silently reverts tracked edits instead; and the nightly run's git diff --exit-code fails a hand-edited SVG only once that edit is committed, so a working-tree edit alone does not reproduce the nightly result.

Embed

<picture>
  <source media="(prefers-color-scheme: dark)" srcset="docs/diagrams/NN-name.dark.svg">
  <img alt="What the figure claims, in one or two sentences." src="docs/diagrams/NN-name.svg">
</picture>

*Figure N. One-sentence claim.* Derived from `docs/...` and `path/to/source.kt`;
source [`docs/diagrams/NN-name.mmd`](docs/diagrams/NN-name.mmd).

GitHub's sanitizer keeps <picture>, <source media> and <img width>, which is why the pair above survives on the repository page. To see a page as GitHub renders it, post its Markdown to the renderer with gh api /markdown -f mode=gfm -F [email protected] and open the HTML it returns in a headless browser. Block external hosts there with page.route and wait for domcontentloaded, or the README's badges hold the load event open.

Paths are relative to the Markdown file. Renders carry absolute width and height, so a wide figure scales down to the column and a narrow one keeps its 14 px text.

Screenshots

Screenshots are not rendered; they are captured from a running demo warehouse by tests/e2e/scripts/capture-screens.ts into ../media/screens/ with a manifest.json, under the style guide's screenshot rules. Against an isolated nginx stack raised as deploying Karyo describes, running with KARYO_DEMO=on, with a manager granted on Lumen Home Goods or the Company, an operator granted on Riverside DC and an administrator who holds settings.manage at the Company (the script switches the profile, and puts it back on Core). The seed creates Lumen's Riverside DC and Hillcrest DC, plus Cobalt Outdoor's Eastport DC:

The demo seed truncates operational tables across the database. Use a disposable database, never a shared warehouse. For an isolated HTTPS stack with a self-signed certificate, set KARYO_E2E_ALLOW_SELF_SIGNED=true only for the capture process; this does not change host trust. The script reads the seed response's tree and selects Riverside DC explicitly in both apps, even when a Company grant reaches other sites. A picker with one choice is left as it is.

cd tests/e2e
BASE_URL=http://localhost:18088 \
KARYO_E2E_MANAGER_USER=... KARYO_E2E_MANAGER_PASSWORD=... \
KARYO_E2E_OPERATOR_USER=... KARYO_E2E_OPERATOR_PASSWORD=... \
KARYO_E2E_ADMIN_USER=... KARYO_E2E_ADMIN_PASSWORD=... \
KARYO_E2E_LOCI_URL=http://<host>:<port> \
npm run screens

Name the three accounts like people (the header shows the name): a console that reads e2e-suite-manager is a test harness, not a warehouse. KARYO_E2E_LOCI_URL is optional: it is the address of a Loci that the application can reach, and without it the Slotting page, which needs one, is left out of the extended set. The script captures the core set on Core, then the extended set on Extended, and waits for the monitor evaluator's first alerts (up to its five-minute interval) so that the Monitors page shows its work.

The script seeds the demo warehouse (the seed resets first, so it is idempotent), then pins the browser clock to the next whole minute, so nothing the seed wrote reads later than the header clock, and rewrites every PNG and the manifest. Pixels are not byte-stable across machines, so CI never re-captures; the consistency test guards the manifest, and re-capture is a manual step after a UI change that alters a captured screen, reviewed by eye.

Figures

Source Look Used in
00-grammar-legend clean the style guide
01-warehouse-execution-flow hand-drawn README lead
02-capability-map clean README "One product", engine boundaries
03-service-architecture clean architecture overview
04-karyo-loci-boundary clean engine boundaries
05-deployment-topology clean README "How it is built", architecture overview
06-one-repository-distribution clean ADR 0029
07-slotting-boundary-inside clean ADR 0029
08-licence-compatibility-bridge clean ADR 0030
09-first-inbound-outbound-flow clean implementer guide
10-release-gate-flow clean releasing.md
11-stock-and-place-cluster clean data model
12-order-to-shipment-chain clean data model
13-asn-to-goods-receipt clean data model
14-principal-identity-boundary clean identity and tenancy