Skill Tracer
Skills › Scientific Agent Skills › markdown-mermaid-writing › mermaid_style_guide.md

mermaid_style_guide.md

473 lines · skills/markdown-mermaid-writing/references/mermaid_style_guide.md at 5f2bc03

Open on GitHub

Most marks come from matching words in the file, so treat them as pointers.

1<!-- Source: https://github.com/SuperiorByteWorks-LLC/agent-project | License: Apache-2.0 | Author: Clayton Young / Superior Byte Works, LLC (Boreal Bytes) -->
2
3# Mermaid Diagram Style Guide
4
5> **For AI agents:** Read this file for all core styling rules. Then use the [diagram selection table](#choosing-the-right-diagram) to pick the right type and follow its link — each type has its own file with a production-quality exemplar, tips, and a copy-paste template.
6>
7> **For humans:** This guide + the linked diagram files provide a starting point for readable diagrams; validate rendering and accessibility in the actual destination. Reference it from your `AGENTS.md` or contributing guide.
8
9**Target platform:** Mermaid-capable Markdown; check the particular host and version.
10**Verified renderer:** Mermaid 12.0.0. See [Current rendering and validation](current-rendering.md) for CLI export, browser APIs, and accessibility results.
11These are house-style preferences, not Mermaid grammar or universal GitHub guarantees.
12All business workflows, endpoints, scores, and dates in examples are illustrative.
13**Design goal:** Minimal professional styling that renders beautifully in both GitHub light and dark modes, is accessible to screen readers, and communicates clearly with zero visual noise.
15---

<!-- Source: https://github.com/SuperiorByteWorks-LLC/agent-project | License: Apache-2.0 | Author: Clayton Young / Superior Byte Works, LLC (Boreal Bytes) -->

Mermaid Diagram Style Guide

For AI agents: Read this file for all core styling rules. Then use the diagram selection table to pick the right type and follow its link — each type has its own file with a production-quality exemplar, tips, and a copy-paste template. For humans: This guide + the linked diagram files provide a starting point for readable diagrams; validate rendering and accessibility in the actual destination. Reference it from your AGENTS.md or contributing guide.

Target platform: Mermaid-capable Markdown; check the particular host and version. Verified renderer: Mermaid 12.0.0. See Current rendering and validation for CLI export, browser APIs, and accessibility results. These are house-style preferences, not Mermaid grammar or universal GitHub guarantees. All business workflows, endpoints, scores, and dates in examples are illustrative. Design goal: Minimal professional styling that renders beautifully in both GitHub light and dark modes, is accessible to screen readers, and communicates clearly with zero visual noise.


Raw lines 1 to 16
Project instruction file AGENTS.md :7
17## Quick Start for Agents
191. **Pick the diagram type** → [Selection table](#choosing-the-right-diagram)
202. **Open that type's file** → Copy the template, fill in your content
213. **Apply styling from this file** → Emoji from [approved set](#approved-emoji-set), colors from [approved palette](#github-compatible-color-classes)
224. **Add accessibility** → `accTitle` + `accDescr` (or italic Markdown paragraph for unsupported types)
235. **Verify** → Renders in light mode, dark mode, and screen reader
25---

Quick Start for Agents

  1. Pick the diagram type → Selection table
  2. Open that type's file → Copy the template, fill in your content
  3. Apply styling from this file → Emoji from approved set, colors from approved palette
  4. Add accessibility → accTitle + accDescr (or italic Markdown paragraph for unsupported types)
  5. Verify → Renders in light mode, dark mode, and screen reader

Raw lines 17 to 26
27## Core Principles
29| # | Principle | Rule |
30| --- | ------------------------------ | ------------------------------------------------------------------------------------------------------ |
31| 1 | **Clarity at every scale** | Simple diagrams stay flat. Complex ones use subgraphs. Very complex ones split into overview + detail. |
32| 2 | **Accessibility always** | Use supported SVG metadata plus a visible description; verify the exported result. |
33| 3 | **Theme neutral** | Prefer host themes and documented per-type styling; verify contrast. |
34| 4 | **Semantic clarity** | `snake_case` node IDs that match labels. Active voice. Sentence case. |
35| 5 | **Consistent styling** | Same emoji = same meaning everywhere. Same shapes = same semantics. |
36| 6 | **Minimal professional flair** | A touch of emoji + strategic bold + optional `classDef` — never more. |
38---

Core Principles

#PrincipleRule
1Clarity at every scaleSimple diagrams stay flat. Complex ones use subgraphs. Very complex ones split into overview + detail.
2Accessibility alwaysUse supported SVG metadata plus a visible description; verify the exported result.
3Theme neutralPrefer host themes and documented per-type styling; verify contrast.
4Semantic claritysnake_case node IDs that match labels. Active voice. Sentence case.
5Consistent stylingSame emoji = same meaning everywhere. Same shapes = same semantics.
6Minimal professional flairA touch of emoji + strategic bold + optional classDef — never more.

Raw lines 27 to 39
40## Accessibility Requirements
42**Use both annotations where the renderer supports them:**
44```
45accTitle: Short Name 3-8 Words
46accDescr: One or two sentences explaining what this diagram shows and what insight the reader gains from it
47```
49- `accTitle` — 3–8 words, plain text, names the diagram
50- `accDescr` — 1–2 sentences; single-line form is convenient. Mermaid also supports `accDescr { ... }` across multiple lines
52Mermaid 12.0.0 emits these annotations for flowchart, sequence, class, state, ER,
53gantt, pie, git graph, journey, requirement, quadrant, XY, architecture, packet,
54radar, and treemap. Block, kanban, mindmap, and Sankey need a visible text alternative.
55Timeline accepts annotations but the tested SVG omitted both; C4 omitted the SVG title.
56ZenUML is a separate plugin. See the tested matrix in [Current rendering and validation](current-rendering.md).
57A paragraph does not automatically become an SVG accessible name; include meaningful image
58alt text when exporting, and a data table or detailed equivalent for complex figures.
60> **ZenUML note:** ZenUML requires an external plugin and may not render on GitHub. Prefer standard `sequenceDiagram` syntax.
62---

Accessibility Requirements

Use both annotations where the renderer supports them:

accTitle: Short Name 3-8 Words
accDescr: One or two sentences explaining what this diagram shows and what insight the reader gains from it
  • accTitle — 3–8 words, plain text, names the diagram
  • accDescr — 1–2 sentences; single-line form is convenient. Mermaid also supports accDescr { ... } across multiple lines

Mermaid 12.0.0 emits these annotations for flowchart, sequence, class, state, ER, gantt, pie, git graph, journey, requirement, quadrant, XY, architecture, packet, radar, and treemap. Block, kanban, mindmap, and Sankey need a visible text alternative. Timeline accepts annotations but the tested SVG omitted both; C4 omitted the SVG title. ZenUML is a separate plugin. See the tested matrix in Current rendering and validation. A paragraph does not automatically become an SVG accessible name; include meaningful image alt text when exporting, and a data table or detailed equivalent for complex figures.

ZenUML note: ZenUML requires an external plugin and may not render on GitHub. Prefer standard sequenceDiagram syntax.

Raw lines 40 to 63
64## Theme Configuration

Theme Configuration

Raw lines 64 to 65
66### ✅ Do: No theme directive (GitHub auto-detects)
68```mermaid
69flowchart LR
70 accTitle: Secure API Request Flow
71 accDescr: Three-step API request from authentication through processing to response
73 auth[🔐 Authenticate] --> process[⚙️ Process request] --> respond[📤 Return response]
74```

✅ Do: No theme directive (GitHub auto-detects)

flowchart LR
    accTitle: Secure API Request Flow
    accDescr: Three-step API request from authentication through processing to response

    auth[🔐 Authenticate] --> process[⚙️ Process request] --> respond[📤 Return response]
Raw lines 66 to 75
76### Prefer host defaults unless custom styling is required
78```
79%% Custom colors may reduce contrast; inspect both themes
80style A fill:#e8f5e9
81%%{init: {'theme':'base'}}%%
82```
84---

Prefer host defaults unless custom styling is required

%% Custom colors may reduce contrast; inspect both themes
style A fill:#e8f5e9
%%{init: {'theme':'base'}}%%

Raw lines 76 to 85
86## Approved Emoji Set
88One emoji per node, at the start of the label. Same emoji = same meaning across all diagrams in a project.

Approved Emoji Set

One emoji per node, at the start of the label. Same emoji = same meaning across all diagrams in a project.

Raw lines 86 to 89
90### Systems & Infrastructure
92| Emoji | Meaning | Example |
93| ----- | --------------------------------- | ------------------------- |
94| ☁️ | Cloud / platform / hosted service | `[☁️ AWS Lambda]` |
95| 🌐 | Network / web / connectivity | `[🌐 API gateway]` |
96| 🖥️ | Server / compute / machine | `[🖥️ Application server]` |
97| 💾 | Storage / database / persistence | `[💾 PostgreSQL]` |
98| 🔌 | Integration / plugin / connector | `[🔌 Webhook handler]` |

Systems & Infrastructure

EmojiMeaningExample
☁️Cloud / platform / hosted service[☁️ AWS Lambda]
🌐Network / web / connectivity[🌐 API gateway]
🖥️Server / compute / machine[🖥️ Application server]
💾Storage / database / persistence[💾 PostgreSQL]
🔌Integration / plugin / connector[🔌 Webhook handler]
Raw lines 90 to 99
100### Processes & Actions
102| Emoji | Meaning | Example |
103| ----- | -------------------------------- | ------------------------- |
104| ⚙️ | Process / configuration / engine | `[⚙️ Build pipeline]` |
105| 🔄 | Cycle / sync / recurring process | `[🔄 Retry loop]` |
106| 🚀 | Deploy / launch / release | `[🚀 Ship to production]` |
107| ⚡ | Fast action / trigger / event | `[⚡ Webhook fired]` |
108| 📦 | Package / artifact / bundle | `[📦 Docker image]` |
109| 🔧 | Tool / utility / maintenance | `[🔧 Migration script]` |
110| ⏰ | Scheduled / cron / time-based | `[⏰ Nightly job]` |

Processes & Actions

EmojiMeaningExample
⚙️Process / configuration / engine[⚙️ Build pipeline]
🔄Cycle / sync / recurring process[🔄 Retry loop]
🚀Deploy / launch / release[🚀 Ship to production]
⚡Fast action / trigger / event[⚡ Webhook fired]
📦Package / artifact / bundle[📦 Docker image]
🔧Tool / utility / maintenance[🔧 Migration script]
⏰Scheduled / cron / time-based[⏰ Nightly job]
Raw lines 100 to 111
112### People & Roles
114| Emoji | Meaning | Example |
115| ----- | ---------------------------- | -------------------- |
116| 👤 | User / person / actor | `[👤 End user]` |
117| 👥 | Team / group / organization | `[👥 Platform team]` |
118| 🤖 | Bot / agent / automation | `[🤖 CI bot]` |
119| 🧠 | Intelligence / decision / AI | `[🧠 ML classifier]` |

People & Roles

EmojiMeaningExample
👤User / person / actor[👤 End user]
👥Team / group / organization[👥 Platform team]
🤖Bot / agent / automation[🤖 CI bot]
🧠Intelligence / decision / AI[🧠 ML classifier]
Raw lines 112 to 120
121### Status & Outcomes
123| Emoji | Meaning | Example |
124| ----- | ------------------------------- | ---------------------- |
125| ✅ | Success / approved / complete | `[✅ Tests passed]` |
126| ❌ | Failure / blocked / rejected | `[❌ Build failed]` |
127| ⚠️ | Warning / caution / risk | `[⚠️ Rate limited]` |
128| 🔒 | Locked / restricted / protected | `[🔒 Requires admin]` |
129| 🔐 | Security / encryption / auth | `[🔐 OAuth handshake]` |

Status & Outcomes

EmojiMeaningExample
✅Success / approved / complete[✅ Tests passed]
❌Failure / blocked / rejected[❌ Build failed]
⚠️Warning / caution / risk[⚠️ Rate limited]
🔒Locked / restricted / protected[🔒 Requires admin]
🔐Security / encryption / auth[🔐 OAuth handshake]
Raw lines 121 to 130
131### Information & Data
133| Emoji | Meaning | Example |
134| ----- | ------------------------------- | -------------------- |
135| 📊 | Analytics / metrics / dashboard | `[📊 Usage metrics]` |
136| 📋 | Checklist / form / inventory | `[📋 Requirements]` |
137| 📝 | Document / log / record | `[📝 Audit trail]` |
138| 📥 | Input / receive / ingest | `[📥 Event stream]` |
139| 📤 | Output / send / emit | `[📤 Notification]` |
140| 🔍 | Search / review / inspect | `[🔍 Code review]` |
141| 🏷️ | Label / tag / version | `[🏷️ v2.1.0]` |

Information & Data

EmojiMeaningExample
📊Analytics / metrics / dashboard[📊 Usage metrics]
📋Checklist / form / inventory[📋 Requirements]
📝Document / log / record[📝 Audit trail]
📥Input / receive / ingest[📥 Event stream]
📤Output / send / emit[📤 Notification]
🔍Search / review / inspect[🔍 Code review]
🏷️Label / tag / version[🏷️ v2.1.0]
Raw lines 131 to 142
143### Domain-Specific
145| Emoji | Meaning | Example |
146| ----- | ------------------------------- | ----------------------- |
147| 💰 | Finance / cost / billing | `[💰 Invoice]` |
148| 🧪 | Testing / experiment / QA | `[🧪 A/B test]` |
149| 📚 | Documentation / knowledge base | `[📚 API docs]` |
150| 🎯 | Goal / target / objective | `[🎯 OKR tracking]` |
151| 🗂️ | Category / organize / archive | `[🗂️ Backlog]` |
152| 🔗 | Link / reference / dependency | `[🔗 External API]` |
153| 🛡️ | Protection / guardrail / policy | `[🛡️ Rate limiter]` |
154| 🏁 | Start / finish / milestone | `[🏁 Sprint complete]` |
155| ✏️ | Edit / revise / update | `[✏️ Address feedback]` |
156| 🎨 | Design / creative / UI | `[🎨 Design review]` |
157| 💡 | Idea / insight / inspiration | `[💡 Feature idea]` |

Domain-Specific

EmojiMeaningExample
💰Finance / cost / billing[💰 Invoice]
🧪Testing / experiment / QA[🧪 A/B test]
📚Documentation / knowledge base[📚 API docs]
🎯Goal / target / objective[🎯 OKR tracking]
🗂️Category / organize / archive[🗂️ Backlog]
🔗Link / reference / dependency[🔗 External API]
🛡️Protection / guardrail / policy[🛡️ Rate limiter]
🏁Start / finish / milestone[🏁 Sprint complete]
✏️Edit / revise / update[✏️ Address feedback]
🎨Design / creative / UI[🎨 Design review]
💡Idea / insight / inspiration[💡 Feature idea]
Raw lines 143 to 158
159### Emoji Rules
1611. **Place at start:** `[🔐 Authenticate]` not `[Authenticate 🔐]`
1622. **Max one per node** — never stack
1633. **Consistency is mandatory** — same emoji = same concept across all diagrams
1644. **Not every node needs one** — use on key nodes that benefit from visual distinction
1655. **No decorative emoji:** 🎉 💯 🔥 🎊 💥 ✨ — they add noise, not meaning
167---

Emoji Rules

  1. Place at start: [🔐 Authenticate] not [Authenticate 🔐]
  2. Max one per node — never stack
  3. Consistency is mandatory — same emoji = same concept across all diagrams
  4. Not every node needs one — use on key nodes that benefit from visual distinction
  5. No decorative emoji: 🎉 💯 🔥 🎊 💥 ✨ — they add noise, not meaning

Raw lines 159 to 168
169## Suggested Color Classes
171Use **only** when you genuinely need color-coding (multi-actor diagrams, severity levels). Prefer shapes + emoji first.
173**Suggested palette (verify in your target light and dark themes):**
175| Semantic Use | `classDef` Definition | Visual |
176| ---------------------- | ------------------------------------------------------------ | -------------------------------------------------- |
177| **Primary / action** | `fill:#dbeafe,stroke:#2563eb,stroke-width:2px,color:#1e3a5f` | Light blue fill, blue border, dark navy text |
178| **Success / positive** | `fill:#dcfce7,stroke:#16a34a,stroke-width:2px,color:#14532d` | Light green fill, green border, dark forest text |
179| **Warning / caution** | `fill:#fef9c3,stroke:#ca8a04,stroke-width:2px,color:#713f12` | Light yellow fill, amber border, dark brown text |
180| **Danger / critical** | `fill:#fee2e2,stroke:#dc2626,stroke-width:2px,color:#7f1d1d` | Light red fill, red border, dark crimson text |
181| **Neutral / info** | `fill:#f3f4f6,stroke:#6b7280,stroke-width:2px,color:#1f2937` | Light gray fill, gray border, near-black text |
182| **Accent / highlight** | `fill:#ede9fe,stroke:#7c3aed,stroke-width:2px,color:#3b0764` | Light violet fill, purple border, dark purple text |
183| **Warm / commercial** | `fill:#ffedd5,stroke:#ea580c,stroke-width:2px,color:#7c2d12` | Light peach fill, orange border, dark rust text |
185**Live preview — all 7 classes rendered:**
187```mermaid
188flowchart LR
189 accTitle: Color Palette Preview
190 accDescr: Visual reference showing all seven approved classDef color classes side by side
192 primary[🔵 Primary] ~~~ success[✅ Success] ~~~ warning[⚠️ Warning] ~~~ danger[❌ Danger]
193 neutral[ℹ️ Neutral] ~~~ accent[🟣 Accent] ~~~ warm[🟠 Warm]
195 classDef primary fill:#dbeafe,stroke:#2563eb,stroke-width:2px,color:#1e3a5f
196 classDef success fill:#dcfce7,stroke:#16a34a,stroke-width:2px,color:#14532d
197 classDef warning fill:#fef9c3,stroke:#ca8a04,stroke-width:2px,color:#713f12
198 classDef danger fill:#fee2e2,stroke:#dc2626,stroke-width:2px,color:#7f1d1d
199 classDef neutral fill:#f3f4f6,stroke:#6b7280,stroke-width:2px,color:#1f2937
200 classDef accent fill:#ede9fe,stroke:#7c3aed,stroke-width:2px,color:#3b0764
201 classDef warm fill:#ffedd5,stroke:#ea580c,stroke-width:2px,color:#7c2d12
203 class primary primary
204 class success success
205 class warning warning
206 class danger danger
207 class neutral neutral
208 class accent accent
209 class warm warm
210```
212**Rules:**
2141. Always include `color:` (text color) — dark-mode backgrounds can hide default text
2152. Use `classDef` + `class` where the diagram supports them. `style` is valid Mermaid syntax; C4 and sequence use different styling mechanisms
2163. Max **3–4 color classes** per diagram
2174. **Never rely on color alone** — always pair with emoji, shape, or label text
219---

Suggested Color Classes

Use only when you genuinely need color-coding (multi-actor diagrams, severity levels). Prefer shapes + emoji first.

Suggested palette (verify in your target light and dark themes):

Semantic UseclassDef DefinitionVisual
Primary / actionfill:#dbeafe,stroke:#2563eb,stroke-width:2px,color:#1e3a5fLight blue fill, blue border, dark navy text
Success / positivefill:#dcfce7,stroke:#16a34a,stroke-width:2px,color:#14532dLight green fill, green border, dark forest text
Warning / cautionfill:#fef9c3,stroke:#ca8a04,stroke-width:2px,color:#713f12Light yellow fill, amber border, dark brown text
Danger / criticalfill:#fee2e2,stroke:#dc2626,stroke-width:2px,color:#7f1d1dLight red fill, red border, dark crimson text
Neutral / infofill:#f3f4f6,stroke:#6b7280,stroke-width:2px,color:#1f2937Light gray fill, gray border, near-black text
Accent / highlightfill:#ede9fe,stroke:#7c3aed,stroke-width:2px,color:#3b0764Light violet fill, purple border, dark purple text
Warm / commercialfill:#ffedd5,stroke:#ea580c,stroke-width:2px,color:#7c2d12Light peach fill, orange border, dark rust text

Live preview — all 7 classes rendered:

flowchart LR
    accTitle: Color Palette Preview
    accDescr: Visual reference showing all seven approved classDef color classes side by side

    primary[🔵 Primary] ~~~ success[✅ Success] ~~~ warning[⚠️ Warning] ~~~ danger[❌ Danger]
    neutral[ℹ️ Neutral] ~~~ accent[🟣 Accent] ~~~ warm[🟠 Warm]

    classDef primary fill:#dbeafe,stroke:#2563eb,stroke-width:2px,color:#1e3a5f
    classDef success fill:#dcfce7,stroke:#16a34a,stroke-width:2px,color:#14532d
    classDef warning fill:#fef9c3,stroke:#ca8a04,stroke-width:2px,color:#713f12
    classDef danger fill:#fee2e2,stroke:#dc2626,stroke-width:2px,color:#7f1d1d
    classDef neutral fill:#f3f4f6,stroke:#6b7280,stroke-width:2px,color:#1f2937
    classDef accent fill:#ede9fe,stroke:#7c3aed,stroke-width:2px,color:#3b0764
    classDef warm fill:#ffedd5,stroke:#ea580c,stroke-width:2px,color:#7c2d12

    class primary primary
    class success success
    class warning warning
    class danger danger
    class neutral neutral
    class accent accent
    class warm warm

Rules:

  1. Always include color: (text color) — dark-mode backgrounds can hide default text
  2. Use classDef + class where the diagram supports them. style is valid Mermaid syntax; C4 and sequence use different styling mechanisms
  3. Max 3–4 color classes per diagram
  4. Never rely on color alone — always pair with emoji, shape, or label text

Raw lines 169 to 220
221## Node Naming & Labels
223| Rule | ✅ Good | ❌ Bad |
224| --------------------- | -------------------------- | ----------------------------------- |
225| `snake_case` IDs | `run_tests`, `deploy_prod` | `A`, `B`, `node1` |
226| IDs match labels | `open_pr` → "Open PR" | `x` → "Open PR" |
227| Specific names | `check_unit_tests` | `check` |
228| Verbs for actions | `run_lint`, `deploy_app` | `linter`, `deployment` |
229| Nouns for states | `review_state`, `error` | `reviewing`, `erroring` |
230| 3–6 word labels | `[📥 Fetch raw data]` | `[Raw data is fetched from source]` |
231| Active voice | `[🧪 Run tests]` | `[Tests are run]` |
232| Sentence case | `[Start pipeline]` | `[Start Pipeline]` |
233| Edge labels 1–4 words | A short phrase such as `Yes` | Long sentence labels |
235---

Node Naming & Labels

Rule✅ Good❌ Bad
snake_case IDsrun_tests, deploy_prodA, B, node1
IDs match labelsopen_pr → "Open PR"x → "Open PR"
Specific namescheck_unit_testscheck
Verbs for actionsrun_lint, deploy_applinter, deployment
Nouns for statesreview_state, errorreviewing, erroring
3–6 word labels[📥 Fetch raw data][Raw data is fetched from source]
Active voice[🧪 Run tests][Tests are run]
Sentence case[Start pipeline][Start Pipeline]
Edge labels 1–4 wordsA short phrase such as YesLong sentence labels

Raw lines 221 to 236
237## Node Shapes
239Use shapes consistently to convey node type without color:
241| Shape | Syntax | Meaning |
242| ----------------- | ---------- | ---------------------------- |
243| Rounded rectangle | `([text])` | Start / end / terminal |
244| Rectangle | `[text]` | Process / action / step |
245| Diamond | `{text}` | Decision / condition |
246| Subroutine | `[[text]]` | Subprocess / grouped action |
247| Cylinder | `[(text)]` | Database / data store |
248| Asymmetric | `>text]` | Event / trigger / external |
249| Hexagon | `{{text}}` | Preparation / initialization |
251---

Node Shapes

Use shapes consistently to convey node type without color:

ShapeSyntaxMeaning
Rounded rectangle([text])Start / end / terminal
Rectangle[text]Process / action / step
Diamond{text}Decision / condition
Subroutine[[text]]Subprocess / grouped action
Cylinder[(text)]Database / data store
Asymmetric>text]Event / trigger / external
Hexagon{{text}}Preparation / initialization

Raw lines 237 to 252
253## Bold Text
255Flowchart Markdown strings need double quotes around a backtick-delimited label:
257```mermaid
258flowchart LR
259 accTitle: Markdown Label Example
260 accDescr: Two pipeline stages, with the first label using Markdown emphasis.
261 start["`Run **quality control**`"] --> finish["Review results"]
262```
264Plain labels such as `node[**text**]` do not reliably interpret emphasis. Other
265diagram types have their own formatting support; prefer plain labels unless tested.
267---

Bold Text

Flowchart Markdown strings need double quotes around a backtick-delimited label:

flowchart LR
    accTitle: Markdown Label Example
    accDescr: Two pipeline stages, with the first label using Markdown emphasis.
    start["`Run **quality control**`"] --> finish["Review results"]

Plain labels such as node[**text**] do not reliably interpret emphasis. Other diagram types have their own formatting support; prefer plain labels unless tested.


Raw lines 253 to 268
269## Subgraphs
271Subgraphs are the primary tool for organizing complex diagrams. They create visual groupings that help readers parse structure at a glance.
273```
274subgraph name ["📋 Descriptive Title"]
275 node1 --> node2
276end
277```
279**Subgraph rules:**
281- Quoted titles with emoji: `["🔍 Code Quality"]`
282- Group by stage, domain, team, or layer — whatever creates the clearest mental model
283- 2–6 nodes per subgraph is ideal; up to 8 if tightly related
284- Subgraphs can connect to each other via edges between their internal nodes
285- One level of nesting is acceptable when it genuinely clarifies hierarchy (e.g., a "Backend" subgraph containing "API" and "Workers" subgraphs). Avoid deeper nesting.
286- Give every subgraph a meaningful ID and title — `subgraph deploy ["🚀 Deployment"]` not `subgraph sg3`
288**Connecting subgraphs — choose the right level of detail:**
290Use **subgraph-to-subgraph** edges when the audience needs the high-level flow and internal details would be noise:
292```
293subgraph build ["📦 Build"]
294 compile --> package
295end
296subgraph deploy ["🚀 Deploy"]
297 stage --> prod
298end
299build --> deploy
300```
302Use **internal-node-to-internal-node** edges when the audience needs to see exactly which step hands off to which:
304```
305subgraph build ["📦 Build"]
306 compile --> package
307end
308subgraph deploy ["🚀 Deploy"]
309 stage --> prod
310end
311package --> stage
312```
314**Pick based on your audience:**
316| Audience | Connect via | Why |
317| --------------------- | ----------------------------- | ---------------------------------- |
318| Leadership / overview | Subgraph → subgraph | They need phases, not steps |
319| Engineers / operators | Internal node → internal node | They need the exact handoff points |
320| Mixed / documentation | Both in separate diagrams | Overview diagram + detail diagram |
322---

Subgraphs

Subgraphs are the primary tool for organizing complex diagrams. They create visual groupings that help readers parse structure at a glance.

subgraph name ["📋 Descriptive Title"]
    node1 --> node2
end

Subgraph rules:

  • Quoted titles with emoji: ["🔍 Code Quality"]
  • Group by stage, domain, team, or layer — whatever creates the clearest mental model
  • 2–6 nodes per subgraph is ideal; up to 8 if tightly related
  • Subgraphs can connect to each other via edges between their internal nodes
  • One level of nesting is acceptable when it genuinely clarifies hierarchy (e.g., a "Backend" subgraph containing "API" and "Workers" subgraphs). Avoid deeper nesting.
  • Give every subgraph a meaningful ID and title — subgraph deploy ["🚀 Deployment"] not subgraph sg3

Connecting subgraphs — choose the right level of detail:

Use subgraph-to-subgraph edges when the audience needs the high-level flow and internal details would be noise:

subgraph build ["📦 Build"]
    compile --> package
end
subgraph deploy ["🚀 Deploy"]
    stage --> prod
end
build --> deploy

Use internal-node-to-internal-node edges when the audience needs to see exactly which step hands off to which:

subgraph build ["📦 Build"]
    compile --> package
end
subgraph deploy ["🚀 Deploy"]
    stage --> prod
end
package --> stage

Pick based on your audience:

AudienceConnect viaWhy
Leadership / overviewSubgraph → subgraphThey need phases, not steps
Engineers / operatorsInternal node → internal nodeThey need the exact handoff points
Mixed / documentationBoth in separate diagramsOverview diagram + detail diagram

Raw lines 269 to 323
324## Managing Complexity
326Not every diagram is simple, and that's fine. The goal is **clarity at every scale** — a 5-node flowchart and a 30-node system diagram should both be immediately understandable. Use the right strategy for the complexity level.

Managing Complexity

Not every diagram is simple, and that's fine. The goal is clarity at every scale — a 5-node flowchart and a 30-node system diagram should both be immediately understandable. Use the right strategy for the complexity level.

Raw lines 324 to 327
328### Complexity tiers
330| Tier | Node count | Strategy |
331| ---------------- | ----------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------- |
332| **Simple** | 1–10 nodes | Flat diagram, no subgraphs needed |
333| **Moderate** | 10–20 nodes | **Use subgraphs** to group related nodes into 2–4 logical clusters |
334| **Complex** | 20–30 nodes | **Subgraphs are mandatory.** 3–6 subgraphs, each with a clear title and purpose. Consider whether an overview + detail approach would be clearer. |
335| **Very complex** | 30+ nodes | **Split into multiple diagrams.** Create an overview diagram showing subgraph-level relationships, then a detail diagram per subgraph. Link them in prose. |

Complexity tiers

TierNode countStrategy
Simple1–10 nodesFlat diagram, no subgraphs needed
Moderate10–20 nodesUse subgraphs to group related nodes into 2–4 logical clusters
Complex20–30 nodesSubgraphs are mandatory. 3–6 subgraphs, each with a clear title and purpose. Consider whether an overview + detail approach would be clearer.
Very complex30+ nodesSplit into multiple diagrams. Create an overview diagram showing subgraph-level relationships, then a detail diagram per subgraph. Link them in prose.
Raw lines 328 to 336
337### When to use subgraphs vs. split into multiple diagrams
339**Use subgraphs when:**
341- The connections _between_ groups are essential to understanding (splitting would lose that)
342- A reader needs to see the full picture in one place (e.g., deployment pipeline, request lifecycle)
343- Each group has 2–6 nodes and there are 3–5 groups total
345**Split into multiple diagrams when:**
347- Groups are mostly independent (few cross-group connections)
348- The single diagram would exceed ~30 nodes even with subgraphs
349- Different audiences need different views (overview for leadership, detail for engineers)
350- The diagram is too wide/tall to read without scrolling
352**Use overview + detail pattern when:**
354- You need both the big picture AND the details
355- The overview shows subgraph-level blocks with key connections
356- Each detail diagram zooms into one subgraph with full internal structure
357- Link them: _"See [Managing complexity](#managing-complexity) for the full scaling guidance."_

When to use subgraphs vs. split into multiple diagrams

Use subgraphs when:

  • The connections between groups are essential to understanding (splitting would lose that)
  • A reader needs to see the full picture in one place (e.g., deployment pipeline, request lifecycle)
  • Each group has 2–6 nodes and there are 3–5 groups total

Split into multiple diagrams when:

  • Groups are mostly independent (few cross-group connections)
  • The single diagram would exceed ~30 nodes even with subgraphs
  • Different audiences need different views (overview for leadership, detail for engineers)
  • The diagram is too wide/tall to read without scrolling

Use overview + detail pattern when:

  • You need both the big picture AND the details
  • The overview shows subgraph-level blocks with key connections
  • Each detail diagram zooms into one subgraph with full internal structure
  • Link them: "See Managing complexity for the full scaling guidance."
Raw lines 337 to 358
359### Best practices at any scale
361- **One primary flow direction** per diagram — `TB` for hierarchies/processes, `LR` for pipelines/timelines. Mixed directions confuse readers.
362- **Decision points** — keep to ≤3 per subgraph. If a single subgraph has 4+ decisions, it deserves its own focused diagram.
363- **Edge crossings** — minimize by grouping tightly-connected nodes together. If edges are crossing multiple subgraphs chaotically, reorganize the groupings.
364- **Labels stay concise** regardless of diagram size — 3–6 words per node, 1–4 words per edge. Complexity comes from structure, not verbose labels.
365- **Color-code subgraph purpose** — in complex diagrams, use `classDef` classes to visually distinguish layers (e.g., all "data" nodes in one color, all "API" nodes in another). Max 3–4 classes even in large diagrams.

Best practices at any scale

  • One primary flow direction per diagram — TB for hierarchies/processes, LR for pipelines/timelines. Mixed directions confuse readers.
  • Decision points — keep to ≤3 per subgraph. If a single subgraph has 4+ decisions, it deserves its own focused diagram.
  • Edge crossings — minimize by grouping tightly-connected nodes together. If edges are crossing multiple subgraphs chaotically, reorganize the groupings.
  • Labels stay concise regardless of diagram size — 3–6 words per node, 1–4 words per edge. Complexity comes from structure, not verbose labels.
  • Color-code subgraph purpose — in complex diagrams, use classDef classes to visually distinguish layers (e.g., all "data" nodes in one color, all "API" nodes in another). Max 3–4 classes even in large diagrams.
Raw lines 359 to 366
367### Composing multiple diagrams
369When a single diagram isn't enough — multiple audiences, overview + detail needs, or before/after migration docs — see **[Composing Complex Diagram Sets](diagrams/complex_examples.md)** for patterns and production-quality examples showing how to combine flowcharts, sequences, ER diagrams, and more into cohesive documentation.
371---

Composing multiple diagrams

When a single diagram isn't enough — multiple audiences, overview + detail needs, or before/after migration docs — see Composing Complex Diagram Sets for patterns and production-quality examples showing how to combine flowcharts, sequences, ER diagrams, and more into cohesive documentation.


Raw lines 367 to 372
373## Choosing the Right Diagram
375Read the "best for" column, then follow the link to the type file for the exemplar diagram, tips, and template.
377| You want to show... | Type | File |
378| ---------------------------------------- | ---------------- | --------------------------------------------------- |
379| Steps in a process / decisions | **Flowchart** | [flowchart.md](diagrams/flowchart.md) |
380| Who talks to whom, when | **Sequence** | [sequence.md](diagrams/sequence.md) |
381| Class hierarchy / type relationships | **Class** | [class.md](diagrams/class.md) |
382| Status transitions / lifecycle | **State** | [state.md](diagrams/state.md) |
383| Database schema / data model | **ER** | [er.md](diagrams/er.md) |
384| Project timeline / roadmap | **Gantt** | [gantt.md](diagrams/gantt.md) |
385| Parts of a whole (proportions) | **Pie** | [pie.md](diagrams/pie.md) |
386| Git branching / merge strategy | **Git Graph** | [git_graph.md](diagrams/git_graph.md) |
387| Concept hierarchy / brainstorm | **Mindmap** | [mindmap.md](diagrams/mindmap.md) |
388| Events over time (chronological) | **Timeline** | [timeline.md](diagrams/timeline.md) |
389| User experience / satisfaction map | **User Journey** | [user_journey.md](diagrams/user_journey.md) |
390| Two-axis prioritization / comparison | **Quadrant** | [quadrant.md](diagrams/quadrant.md) |
391| Requirements traceability | **Requirement** | [requirement.md](diagrams/requirement.md) |
392| System architecture (zoom levels) | **C4** | [c4.md](diagrams/c4.md) |
393| Flow magnitude / resource distribution | **Sankey** | [sankey.md](diagrams/sankey.md) |
394| Numeric trends (bar + line charts) | **XY Chart** | [xy_chart.md](diagrams/xy_chart.md) |
395| Component layout / spatial arrangement | **Block** | [block.md](diagrams/block.md) |
396| Work item status board | **Kanban** | [kanban.md](diagrams/kanban.md) |
397| Binary protocol / data format | **Packet** | [packet.md](diagrams/packet.md) |
398| Infrastructure topology | **Architecture** | [architecture.md](diagrams/architecture.md) |
399| Multi-dimensional comparison / skills | **Radar** | [radar.md](diagrams/radar.md) |
400| Hierarchical proportions / budget | **Treemap** | [treemap.md](diagrams/treemap.md) |
401| Code-style sequence (programming syntax) | **ZenUML** | [zenuml.md](diagrams/zenuml.md) |
403**Pick the most specific type.** Don't default to flowcharts — match your content to the diagram type that was designed for it. A sequence diagram communicates service interactions better than a flowchart ever will.
405---

Choosing the Right Diagram

Read the "best for" column, then follow the link to the type file for the exemplar diagram, tips, and template.

You want to show...TypeFile
Steps in a process / decisionsFlowchartflowchart.md
Who talks to whom, whenSequencesequence.md
Class hierarchy / type relationshipsClassclass.md
Status transitions / lifecycleStatestate.md
Database schema / data modelERer.md
Project timeline / roadmapGanttgantt.md
Parts of a whole (proportions)Piepie.md
Git branching / merge strategyGit Graphgit_graph.md
Concept hierarchy / brainstormMindmapmindmap.md
Events over time (chronological)Timelinetimeline.md
User experience / satisfaction mapUser Journeyuser_journey.md
Two-axis prioritization / comparisonQuadrantquadrant.md
Requirements traceabilityRequirementrequirement.md
System architecture (zoom levels)C4c4.md
Flow magnitude / resource distributionSankeysankey.md
Numeric trends (bar + line charts)XY Chartxy_chart.md
Component layout / spatial arrangementBlockblock.md
Work item status boardKanbankanban.md
Binary protocol / data formatPacketpacket.md
Infrastructure topologyArchitecturearchitecture.md
Multi-dimensional comparison / skillsRadarradar.md
Hierarchical proportions / budgetTreemaptreemap.md
Code-style sequence (programming syntax)ZenUMLzenuml.md

Pick the most specific type. Don't default to flowcharts — match your content to the diagram type that was designed for it. A sequence diagram communicates service interactions better than a flowchart ever will.


Raw lines 373 to 406
407## Known Parser Gotchas
409These will save you debugging time:
411| Diagram Type | Gotcha | Fix |
412| ---------------- | ----------------------------------------------- | ------------------------------------------------------------------- |
413| **Architecture** | Label support varies in older hosts | Mermaid 12 accepts Unicode; preview on the destination |
414| **Architecture** | Older hosts may reject punctuation | Mermaid 12 accepts `[US-East Region]`; verify older versions |
415| **Architecture** | `-->` arrow syntax is strict about spacing | Use `lb:R --> L:api` format exactly |
416| **Requirement** | Unquoted punctuation in fields can fail | Quote strings: `id: "REQ-001"`, `docref: "component-ref"` |
417| **Requirement** | Risk and verification use enumerated values | Copy documented values such as `risk: high`, `verifymethod: test` |
418| **C4** | Long descriptions cause label overlaps | Keep descriptions under 4 words; use `UpdateRelStyle()` for offsets |
419| **C4** | Emoji in labels render but look odd | Skip emoji in C4 — renderer has its own icons |
420| **Flowchart** | The word `end` breaks parsing | Wrap in quotes: `["End"]` or use `end_node` as ID |
421| **Sankey** | Emoji labels failed in the tested parser | Prefer plain text; quote fields containing commas or double quotes |
422| **ZenUML** | Requires external plugin | May not render on GitHub — prefer `sequenceDiagram` |
423| **Treemap** | Experimental syntax and host versions vary | Verify the destination renderer before using |
424| **Radar** | Requires v11.6.0+ | Verify GitHub supports it before using |
426---

Known Parser Gotchas

These will save you debugging time:

Diagram TypeGotchaFix
ArchitectureLabel support varies in older hostsMermaid 12 accepts Unicode; preview on the destination
ArchitectureOlder hosts may reject punctuationMermaid 12 accepts [US-East Region]; verify older versions
Architecture--> arrow syntax is strict about spacingUse lb:R --> L:api format exactly
RequirementUnquoted punctuation in fields can failQuote strings: id: "REQ-001", docref: "component-ref"
RequirementRisk and verification use enumerated valuesCopy documented values such as risk: high, verifymethod: test
C4Long descriptions cause label overlapsKeep descriptions under 4 words; use UpdateRelStyle() for offsets
C4Emoji in labels render but look oddSkip emoji in C4 — renderer has its own icons
FlowchartThe word end breaks parsingWrap in quotes: ["End"] or use end_node as ID
SankeyEmoji labels failed in the tested parserPrefer plain text; quote fields containing commas or double quotes
ZenUMLRequires external pluginMay not render on GitHub — prefer sequenceDiagram
TreemapExperimental syntax and host versions varyVerify the destination renderer before using
RadarRequires v11.6.0+Verify GitHub supports it before using

Raw lines 407 to 427
428## Quality Checklist

Quality Checklist

Raw lines 428 to 429
430### Every Diagram
432- [ ] `accTitle` + `accDescr` present (or italic Markdown paragraph for unsupported types)
433- [ ] Complexity managed: ≤10 nodes flat, 10–30 with subgraphs, 30+ split into multiple diagrams
434- [ ] Subgraphs used if >10 nodes (grouped by stage, domain, team, or layer)
435- [ ] ≤3 decision points per subgraph
436- [ ] Semantic `snake_case` IDs
437- [ ] Labels: 3–6 words, active voice, sentence case
438- [ ] Edge labels: 1–4 words
439- [ ] Consistent shapes for consistent meanings
440- [ ] Single primary flow direction (`TB` or `LR`)
441- [ ] Per-type style syntax and readable contrast verified
442- [ ] Minimal edge crossings (reorganize groupings if chaotic)

Every Diagram

  • [ ] accTitle + accDescr present (or italic Markdown paragraph for unsupported types)
  • [ ] Complexity managed: ≤10 nodes flat, 10–30 with subgraphs, 30+ split into multiple diagrams
  • [ ] Subgraphs used if >10 nodes (grouped by stage, domain, team, or layer)
  • [ ] ≤3 decision points per subgraph
  • [ ] Semantic snake_case IDs
  • [ ] Labels: 3–6 words, active voice, sentence case
  • [ ] Edge labels: 1–4 words
  • [ ] Consistent shapes for consistent meanings
  • [ ] Single primary flow direction (TB or LR)
  • [ ] Per-type style syntax and readable contrast verified
  • [ ] Minimal edge crossings (reorganize groupings if chaotic)
Raw lines 430 to 443
444### If Using Color/Emoji/Bold
446- [ ] Colors from approved palette using `classDef` + `class`
447- [ ] Text `color:` included in every `classDef`
448- [ ] ≤4 color classes
449- [ ] Emoji from approved set, max 1 per node
450- [ ] Bold on max 1–2 words per node
451- [ ] Meaning never conveyed by color alone

If Using Color/Emoji/Bold

  • [ ] Colors from approved palette using classDef + class
  • [ ] Text color: included in every classDef
  • [ ] ≤4 color classes
  • [ ] Emoji from approved set, max 1 per node
  • [ ] Bold on max 1–2 words per node
  • [ ] Meaning never conveyed by color alone
Raw lines 444 to 452
453### Before Merge
455- [ ] Renders in GitHub **light** mode
456- [ ] Renders in GitHub **dark** mode
457- [ ] Emoji meanings consistent across all diagrams in the document
459---

Before Merge

  • [ ] Renders in GitHub light mode
  • [ ] Renders in GitHub dark mode
  • [ ] Emoji meanings consistent across all diagrams in the document

Raw lines 453 to 460
461## Testing
4631. **Destination:** Preview in the actual host and toggle its light/dark appearance. Do not publish solely to run a rendering test.
4642. **Local:** Run the pinned CLI examples in [Current rendering and validation](current-rendering.md). Editor preview extensions may bundle another Mermaid version.
4653. **Live editor:** [mermaid.live](https://mermaid.live/) — paste and toggle themes
4664. **Screen reader:** Verify `accTitle`/`accDescr` announced (VoiceOver, NVDA, JAWS)
468---

Testing

  1. Destination: Preview in the actual host and toggle its light/dark appearance. Do not publish solely to run a rendering test.
  2. Local: Run the pinned CLI examples in Current rendering and validation. Editor preview extensions may bundle another Mermaid version.
  3. Live editor: mermaid.live — paste and toggle themes
  4. Screen reader: Verify accTitle/accDescr announced (VoiceOver, NVDA, JAWS)

Raw lines 461 to 469
470## Resources
472- [Markdown Style Guide](markdown_style_guide.md) — Formatting, citations, and document structure for the markdown that wraps your diagrams
473- [Mermaid Docs](https://mermaid.js.org/) · [Live Editor](https://mermaid.live/) · [Accessibility](https://mermaid.js.org/config/accessibility.html) · [GitHub Support](https://github.blog/2022-02-14-include-diagrams-markdown-files-mermaid/) · [Mermaid CLI](https://github.com/mermaid-js/mermaid-cli)

Resources

Raw lines 470 to 473