Diagrams as Code
Choosing the right diagramming tool. Comparison of D2, Mermaid, GraphViz, and PlantUML with workflow patterns and Catppuccin theming.
Tool Selection Guide
| Tool | Best For | Strengths | Learning Curve |
|---|---|---|---|
D2 |
Infrastructure diagrams, architecture |
Clean syntax, native dark themes, containers |
Low |
Mermaid |
Flowcharts, sequences, Gantt charts |
GitHub/GitLab native rendering, wide adoption |
Low |
GraphViz |
Graph theory, dependency trees, large graphs |
Mature layout algorithms, record-based nodes |
Medium |
PlantUML |
UML (class, sequence, component, state) |
Full UML coverage, extensive documentation |
Medium |
Workflow Pattern
# 1. Write diagram source
nvim docs/modules/ROOT/pages/reference/diagrams/network.adoc
# 2. Build locally with Kroki
cd ~/atelier/_bibliotheca/domus-docs && make serve
# 3. Check rendered output
# http://localhost:8000/captures/reference/diagrams/network.html
# 4. Iterate until satisfied, then commit
git -C ~/atelier/_bibliotheca/domus-captures add -A && \
git -C ~/atelier/_bibliotheca/domus-captures commit -m "$(cat <<'EOF'
docs(diagrams): Add network topology diagram
EOF
)"
Syntax Comparison
client -> server: HTTPS
server -> database: SQL
database: PostgreSQL {shape: cylinder}
graph LR
client[Client] -->|HTTPS| server[Server]
server -->|SQL| database[(PostgreSQL)]
digraph {
rankdir=LR
database [shape=cylinder]
client -> server [label="HTTPS"]
server -> database [label="SQL"]
}
@startuml
client -> server: HTTPS
server -> database: SQL
@enduml
Embedding in AsciiDoc
All four tools share the same Kroki integration pattern in AsciiDoc:
[TOOL,target=OUTPUT_NAME,format=svg]
....
diagram source here
....
Replace TOOL with d2, mermaid, graphviz, or plantuml.
File Organization
pages/reference/diagrams/
├── index.adoc # Gallery with inline diagrams
├── architecture.adoc # System architecture diagrams
├── network.adoc # Network topology diagrams
├── security.adoc # Security flow diagrams
├── flows.adoc # Process flow diagrams
└── projects.adoc # Project-specific diagrams
Diagrams live inline in AsciiDoc pages. Kroki renders them at build time — no separate image files to manage.
Catppuccin Mocha Palette Reference
| Color | Hex | Use |
|---|---|---|
Base |
|
Background |
Surface0 |
|
Container fill |
Overlay0 |
|
Subtle borders |
Text |
|
Labels, text |
Blue |
|
Primary elements |
Green |
|
Success, databases |
Pink |
|
Connections, highlights |
Red |
|
Errors, warnings |
Peach |
|
Accents |
Subtext0 |
|
Secondary text, arrows |