๐Ÿ“

Diagram Pattern Comparison

SVG, Mermaid, draw.io, D2, Excalidraw โ€” Which approach to choose

There are broadly 3 approaches to drawing architecture diagrams. Code-based (Mermaid, D2) enables Git diff and CI/CD automation, GUI-based (draw.io, Excalidraw) is accessible to non-developers, and direct rendering (SVG/HTML+CSS) offers full control at higher authoring cost.

Architecture Diagram

3 Approaches
๐Ÿ“
Code-based
Diagrams as Code
Mermaid.js
D2
PlantUML
๐Ÿ–ฑ๏ธ
GUI-based
Drag & Drop
draw.io
Excalidraw
Lucidchart / Figma
๐ŸŽจ
Direct Rendering
SVG / HTML+CSS
Write SVG directly
HTML + Tailwind CSS
(app56 uses this!)
Detailed Tool Comparison
Tool Method Git Diff Layout Control Non-dev CI/CD Automation
Mermaid.js Text Weak Medium
D2 Text Strong Medium
PlantUML Text Medium Hard
draw.io GUI (XML) XML Full Limited
Excalidraw GUI (JSON) JSON Full
SVG Direct Code Full N/A Manual
HTML+CSS Code Full N/A Manual
Same Diagram, Different Syntax
๐Ÿงœ Mermaid.js Renders in GitHub README
graph LR
  A[Client] -->|HTTP| B[Load Balancer]
  B --> C[App Server 1]
  B --> D[App Server 2]
  C --> E[(Database)]
  D --> E
๐Ÿ’Ž D2 Layout control + Themes
client: Client {shape: rectangle}
lb: Load Balancer {shape: hexagon}
app1: App Server 1
app2: App Server 2
db: Database {shape: cylinder}

client -> lb: HTTP
lb -> app1
lb -> app2
app1 -> db
app2 -> db
๐Ÿ–ผ๏ธ draw.io GUI + XML storage
Drag Drop Connect
.drawio (XML) / .svg / .png export
Edit directly in VS Code with extension!
โœ๏ธ Excalidraw Hand-drawn style
Client
--->
Server
--->
DB
JSON storage โ†’ Git manageable
"Unfinished feel" โ†’ Ideal for early discussions
Which tool? โ€” Selection Guide
Display directly<br>in GitHub README?
Mermaid.js
Complex layout<br>+ Git management?
D2
Non-devs<br>need to edit?
draw.io
Team brainstorming<br>/ initial design?
Excalidraw
Interactive<br>in web app?
SVG / HTML+CSS
AI auto-<br>generation?
Mermaid / D2
Claude/GPT generates on the fly
Git Workflow Comparison
Code-based (Mermaid/D2)
# Check changes in PR diff
- A -->|HTTP| B
+ A -->|gRPC| B
Reviewers instantly understand the change
Binary (PNG/Figma)
Binary files a/diagram.png
and b/diagram.png differ
Cannot tell what changed
draw.io (XML)
&lt;!-- diff possible but --&gt;
<mxCell value="Server"
x="340" y="180"/>
Diffable but hard to read
Recommendation: Official docs = draw.io, Code review = Mermaid/D2, Brainstorming = Excalidraw, In-app = HTML+CSS

How It Works

1

Direct SVG: Code shapes, lines, and text with <svg> tags. Full pixel control, but highest authoring cost

2

HTML+CSS (app56 approach): Compose diagrams with Tailwind boxes + flexbox/grid. Responsive, same stack as code

3

Mermaid.js: Declare as text in markdown code blocks โ†’ auto-rendered. Displays directly in GitHub/GitLab READMEs

4

D2: Declarative diagram language. Superior layout control over Mermaid with powerful theming/styling

5

draw.io (diagrams.net): GUI editor with drag & drop. Saved as XML for Git management. VS Code extension available

6

Excalidraw: Hand-drawn style whiteboard. Great for brainstorming and initial design. JSON storage for Git management

Pros

  • Code-based: Git diff enabled, changes visible in PR reviews
  • Code-based: Auto-rendering in CI/CD (mermaid-cli, d2)
  • GUI-based: Editable by non-developers
  • draw.io: XML storage enables Git management + VS Code extension
  • Excalidraw: Hand-drawn style feels "unfinished" โ€” ideal for early discussions
  • AI era: ChatGPT/Claude can generate Mermaid/D2 code on the fly

Cons

  • Code-based: Hard to control complex layouts (relies on auto-layout)
  • Mermaid: Readability drops in large diagrams
  • GUI-based: Binary files cannot be Git diffed (Lucidchart, Figma, etc.)
  • Direct SVG: High authoring cost and hard to maintain
  • draw.io XML: Fragile when manually edited
  • Excalidraw: Too casual for official documentation

Use Cases

Tech blogs / documentation (Mermaid โ†’ GitHub README) ADR (Architecture Decision Record) attachments (D2, Mermaid) Official architecture docs (draw.io โ†’ SVG export) Team brainstorming / initial design (Excalidraw) Interactive diagrams in web apps (SVG/HTML+CSS) CI/CD auto-generation (Mermaid CLI, D2 CLI โ†’ PNG/SVG)