Mermaid Architecture Diagrams
Produce diagrams that are correct, legible in print, and consistent as a set — not just syntactically valid Mermaid.
The one non-negotiable rule
Never trust unrendered diagram code. Mermaid layout is emergent: label widths, edge routing, and subgraph sizing only exist after rendering. The loop is:
- Author the
.mmd
- Render it:
scripts/render-mmd.sh diagram.mmd
- Look at the preview image (the script writes a
*-preview.png sized for inspection)
- Fix clipping, overlaps, label collisions, edge crossings — re-render
- Repeat until clean (minimum one fix round; diagrams are never right first try)
A diagram you haven't looked at is a draft, not a deliverable.
Workflow
- Purpose first. One diagram, one purpose, one audience. Write the 5-second story the reader must grasp (what talks to what, through what, where the boundaries are) before drawing. If a diagram needs two stories, make two diagrams.
- Pick the flow direction. Topology/containment reads top-down (
TB); pipelines read left-to-right (LR) — but for print/PDF destinations, tall-and-narrow TB beats wide LR: an LR pipeline scaled to text width prints at ~4–5pt. Verified repeatedly.
- Apply the design system. Use the semantic tokens, edge grammar, and label rules in DESIGN-SYSTEM.md. Color means something or it isn't used. Default to the glass + elevation look (Look 2, judged 8/10); the flat look (5/10) is the exception — reach for it only when colorblind-safety or compliance is explicitly required. "Unknown audience" or "just show me X" is a Look 2 case. See DESIGN-SYSTEM.md's decision rule; don't pick flat because it's listed first.
- Author within the verified allowlist. TECHNIQUES.md contains only constructs verified through real render pipelines, each tagged with where it works. The headline trap: never set
themeVariables.fontFamily for Quarto-destined diagrams — it clips every label.
- Render with the destination's pipeline (table below).
- Self-review adversarially against REVIEW-CHECKLIST.md — legibility, design consistency, comprehension/correctness. Fix and re-render.
- High stakes? Run a variant competition (sketch in REVIEW-CHECKLIST.md): several styled variants, adversarial judging, recombine winners.
Which pipeline renders the truth?
Preview with whatever will render the diagram in production — otherwise you are tuning against the wrong engine:
| Destination |
Render with |
Notes |
| Quarto / pandoc document (PDF, docx) |
render-mmd.sh -p quarto |
The document's own engine; what you see is what ships |
| GitHub README / wiki / GitLab |
render-mmd.sh -p mmdc |
mermaid-cli tracks current Mermaid, closest to GitHub's renderer |
| MkDocs / Docusaurus / Hugo site |
The site's own build; fall back to mmdc for quick iteration |
Site plugins pin their own Mermaid versions |
| Slides, standalone images |
mmdc (-o out.svg for vectors) |
|
render-mmd.sh auto-detects (-p auto, the default): prefers Quarto when installed, falls back to mermaid-cli. Both paths produce a full-resolution PNG plus an inspection preview.
Engine reality check
Quarto bundles its own Mermaid (e.g. 11.6.0) with its own screenshot machinery; mmdc ships current Mermaid (e.g. 11.12). Same major version — different behavior: parser strictness, font handling, and theme defaults all differ. That is why TECHNIQUES.md tags every construct [universal], [quarto], [mmdc], or [version-sensitive], and why the portable strategy is to author inside the intersection: full classDef tokens (never rely on theme defaults), no fontFamily override, filters via themeCSS not classDef, subgraph titles ≤24 characters. Diagrams written that way render near-identically in both pipelines.
When you meet a new pipeline (different SSG, different Mermaid version), spike it first: render TECHNIQUES.md's probe snippets through it and note divergences before authoring real diagrams.
Bundled references
- DESIGN-SYSTEM.md — semantic color tokens (colorblind-safe default palette), edge grammar, layout, label and legend rules
- TECHNIQUES.md — verified syntax allowlist with pipeline tags, gotcha table, probe snippets
- REVIEW-CHECKLIST.md — adversarial self-review lenses + the variant-competition pattern
- scripts/render-mmd.sh — adaptive render + preview loop (Quarto or mermaid-cli)
1---2name: mermaid-architecture-diagrams3description: Author print-quality Mermaid architecture and ops diagrams (system sketches, deployment pipelines, monitoring and data-flow maps) using a semantic color system and a mandatory render-and-inspect loop. Use when creating, styling, or reviewing Mermaid diagrams; when asked for an architecture diagram, system sketch, or flowchart destined for documentation (Quarto/pandoc/PDF, GitHub README, wikis); or when a Mermaid diagram renders ugly, clipped, or unreadable. Covers verified pipeline-specific gotchas (Quarto vs mermaid-cli) and their workarounds.4---56# Mermaid Architecture Diagrams78Produce diagrams that are **correct, legible in print, and consistent as a set** — not just syntactically valid Mermaid.910## The one non-negotiable rule1112**Never trust unrendered diagram code.** Mermaid layout is emergent: label widths, edge routing, and subgraph sizing only exist after rendering. The loop is:13141. Author the `.mmd`152. Render it: `scripts/render-mmd.sh diagram.mmd`163. **Look at the preview image** (the script writes a `*-preview.png` sized for inspection)174. Fix clipping, overlaps, label collisions, edge crossings — re-render185. Repeat until clean (minimum one fix round; diagrams are never right first try)1920A diagram you haven't looked at is a draft, not a deliverable.2122## Workflow23241. **Purpose first.** One diagram, one purpose, one audience. Write the 5-second story the reader must grasp (*what talks to what, through what, where the boundaries are*) before drawing. If a diagram needs two stories, make two diagrams.252. **Pick the flow direction.** Topology/containment reads top-down (`TB`); pipelines read left-to-right (`LR`) — **but for print/PDF destinations, tall-and-narrow TB beats wide LR**: an LR pipeline scaled to text width prints at ~4–5pt. Verified repeatedly.263. **Apply the design system.** Use the semantic tokens, edge grammar, and label rules in [DESIGN-SYSTEM.md](DESIGN-SYSTEM.md). Color means something or it isn't used. **Default to the glass + elevation look (Look 2, judged 8/10); the flat look (5/10) is the exception** — reach for it only when colorblind-safety or compliance is explicitly required. "Unknown audience" or "just show me X" is a Look 2 case. See DESIGN-SYSTEM.md's decision rule; don't pick flat because it's listed first.274. **Author within the verified allowlist.** [TECHNIQUES.md](TECHNIQUES.md) contains only constructs verified through real render pipelines, each tagged with where it works. The headline trap: **never set `themeVariables.fontFamily` for Quarto-destined diagrams** — it clips every label.285. **Render with the destination's pipeline** (table below).296. **Self-review adversarially** against [REVIEW-CHECKLIST.md](REVIEW-CHECKLIST.md) — legibility, design consistency, comprehension/correctness. Fix and re-render.307. **High stakes?** Run a variant competition (sketch in REVIEW-CHECKLIST.md): several styled variants, adversarial judging, recombine winners.3132## Which pipeline renders the truth?3334Preview with whatever will render the diagram in production — otherwise you are tuning against the wrong engine:3536| Destination | Render with | Notes |37|---|---|---|38| Quarto / pandoc document (PDF, docx) | `render-mmd.sh -p quarto` | The document's own engine; what you see is what ships |39| GitHub README / wiki / GitLab | `render-mmd.sh -p mmdc` | mermaid-cli tracks current Mermaid, closest to GitHub's renderer |40| MkDocs / Docusaurus / Hugo site | The site's own build; fall back to `mmdc` for quick iteration | Site plugins pin their own Mermaid versions |41| Slides, standalone images | `mmdc` (`-o out.svg` for vectors) | |4243`render-mmd.sh` auto-detects (`-p auto`, the default): prefers Quarto when installed, falls back to mermaid-cli. Both paths produce a full-resolution PNG plus an inspection preview.4445## Engine reality check4647Quarto bundles its own Mermaid (e.g. 11.6.0) with its own screenshot machinery; `mmdc` ships current Mermaid (e.g. 11.12). Same major version — **different behavior**: parser strictness, font handling, and theme defaults all differ. That is why TECHNIQUES.md tags every construct `[universal]`, `[quarto]`, `[mmdc]`, or `[version-sensitive]`, and why the portable strategy is to **author inside the intersection**: full classDef tokens (never rely on theme defaults), no fontFamily override, filters via `themeCSS` not classDef, subgraph titles ≤24 characters. Diagrams written that way render near-identically in both pipelines.4849When you meet a new pipeline (different SSG, different Mermaid version), spike it first: render TECHNIQUES.md's probe snippets through it and note divergences before authoring real diagrams.5051## Bundled references5253- [DESIGN-SYSTEM.md](DESIGN-SYSTEM.md) — semantic color tokens (colorblind-safe default palette), edge grammar, layout, label and legend rules54- [TECHNIQUES.md](TECHNIQUES.md) — verified syntax allowlist with pipeline tags, gotcha table, probe snippets55- [REVIEW-CHECKLIST.md](REVIEW-CHECKLIST.md) — adversarial self-review lenses + the variant-competition pattern56- [scripts/render-mmd.sh](scripts/render-mmd.sh) — adaptive render + preview loop (Quarto or mermaid-cli)