Why Most Diagrams Go Stale (and How to Stop It)
The pattern is universal: a developer creates a beautiful architecture diagram in Lucidchart, exports a PNG, drops it in the wiki. Six months later, three services have been added, two renamed, and one deleted. The PNG still shows the original design. Nobody updates it because updating it means opening Lucidchart, finding the file, editing, re-exporting, and re-uploading — a 20-minute job that never makes it onto the sprint board.
The solution is diagrams-as-code: store your diagram as text in the same repository as your code. When the code changes, the diagram changes in the same pull request. This approach is now practical with Mermaid (renders natively in GitHub/GitLab), PlantUML, and Structurizr DSL.
If your diagram can't be reviewed in a pull request diff, it will go stale. Store diagrams as code (Mermaid, PlantUML, Structurizr DSL) in your repo. Export to image only for presentations.
The Diagram Taxonomy: 8 Types, One Decision Matrix
Before picking a tool, pick the right diagram type. Each type answers a different question:
| Diagram Type | Question It Answers | Best Tool | When to Skip It |
|---|---|---|---|
| Flowchart | How does this process flow? What are the decision points? | Mermaid, draw.io | When there's no branching logic |
| Sequence Diagram | Which systems talk to each other, and in what order? | Mermaid, PlantUML | Simple single-service flows |
| Architecture Diagram (C4) | How is the system structured at a high level? | Structurizr, Mermaid C4 | Never — always useful |
| Entity-Relationship (ERD) | What are the data entities and their relationships? | Mermaid, dbdiagram.io | NoSQL with no fixed schema |
| Class Diagram (UML) | What are the classes, interfaces, and inheritance? | PlantUML, IntelliJ | Procedural or functional code |
| State Diagram | What states can an entity be in? What causes transitions? | Mermaid, XState | Entities with no meaningful state |
| Gantt Chart | What's the project timeline and task dependencies? | Mermaid, Tools-Hut Gantt | Ad hoc work with no schedule |
| Mind Map / Concept Map | How do these ideas relate? What's the big picture? | Excalidraw, Miro | Formal architecture work |
Flowcharts: The Workhorse
Flowcharts are the most overused and most useful diagram type. They shine when there are decision points — if branches, error paths, retry loops. They're useless for linear processes with no branching (just use a numbered list).
Good flowchart uses: CI/CD pipeline stages, authentication flows, order processing logic, on-call escalation policies.
Bad flowchart uses: "Here are our four microservices" (use a C4 container diagram instead), "Here's our tech stack" (use a simple list).
Sequence Diagrams: The API Handshake Explainer
Sequence diagrams show time-ordered message exchanges between participants. They're irreplaceable for documenting API integrations, OAuth flows, and microservice choreography. The key rule: every arrow is a network call or function invocation. If an arrow doesn't represent a real message, remove it.
sequenceDiagram
actor User
participant Browser
participant API as API Gateway
participant Auth as Auth Service
participant DB as User DB
User->>Browser: clicks "Sign In"
Browser->>API: POST /auth/login
API->>Auth: validateCredentials(email, pwd)
Auth->>DB: SELECT user WHERE email=?
DB-->>Auth: user record
Auth-->>API: JWT { sub, tier, exp }
API-->>Browser: 200 { access_token, refresh_token }
Browser->>Browser: store tokens in memory / localStorageDon't show every internal function call — only show messages that cross a system boundary (service, database, external API). A sequence diagram with 40 arrows is harder to read than the code itself.
Architecture Diagrams: The C4 Model
Most architecture diagrams fail because they try to show everything at once — deployment topology, service relationships, data flows, and UI screens all on one canvas. The C4 model solves this by defining four zoom levels, each answering a different audience's question:
Context
Your system in the world — what external users and external systems does it interact with? Non-technical stakeholders can read this.
Container
The major deployable units — web app, API, database, message queue. Each box is something you deploy separately.
Component
Inside a single container — the major code modules, services, and their relationships. Developers use this.
Code
Class and interface relationships inside a component. Usually auto-generated by the IDE — rarely drawn by hand.
Most projects only need L1 and L2. Start there. L3 is useful for onboarding new developers to a complex service. L4 is rarely worth maintaining manually.
Entity-Relationship Diagrams (ERDs): Design Your Schema First
ERDs should be drawn before you write migrations — not generated after the fact from an existing schema. A 15-minute ERD session catches foreign key mistakes, missing junction tables, and ambiguous cardinality before they become production data quality problems.
Mermaid's erDiagram syntax is particularly clean:
erDiagram
USER {
uuid id PK
string email UK
string display_name
string tier
timestamp created_at
}
SUBSCRIPTION {
uuid id PK
uuid user_id FK
string stripe_sub_id UK
string status
timestamp renews_at
}
AUDIT_LOG {
uuid id PK
uuid user_id FK
string event_type
string result
timestamp created_at
}
USER ||--o{ SUBSCRIPTION : "has"
USER ||--o{ AUDIT_LOG : "generates"The Tool Landscape: What to Use and When
| Tool | Approach | Best For | Dark Mode | Free |
|---|---|---|---|---|
| Mermaid | Code | Git-stored diagrams, GitHub/GitLab rendering | Yes (theming) | Yes |
| PlantUML | Code | UML class/sequence, Java teams | Via config | Yes |
| Structurizr DSL | Code | C4 model, large codebases | Yes | Partly |
| Excalidraw | Visual | Whiteboard sketches, rough concepts | Yes | Yes |
| draw.io / diagrams.net | Visual | Formal enterprise diagrams, network topology | Yes | Yes |
| Lucidchart | Visual | Team collaboration, non-technical stakeholders | Yes | Limited |
| Figma / FigJam | Visual | UI flows, product wireframes, design handoff | Yes | Limited |
| dbdiagram.io | Code | Database schema design specifically | Yes | Yes |
- Mermaid for all text-based diagrams stored in the repo
- Excalidraw for whiteboard sessions and rough concepts
- draw.io for complex network/infrastructure diagrams that don't fit Mermaid
This covers 95% of real engineering diagramming needs at zero cost.
Embedding Diagrams in Documentation
GitHub/GitLab Markdown: Wrap Mermaid code in a fenced code block with mermaid language hint. Both platforms render it natively — no plugin needed.
Confluence: Use the Mermaid for Confluence app (free, marketplace), or embed draw.io diagrams which have native integration.
Notion: Copy-paste into a code block with the Mermaid language — renders inline.
VS Code: Install the Markdown Preview Mermaid Support extension. Live preview as you type.
Docusaurus / MkDocs: Both have Mermaid plugins that render diagrams in your generated docs site.
The Diagram Review Checklist
Before sharing any diagram, run through these questions:
- Does the title clearly state what this diagram shows?
- Is there a legend if you're using custom shapes or colors?
- Does every arrow have a label explaining what flows across it?
- Is the level of detail consistent? (Don't mix L1 and L3 C4 on the same canvas.)
- Does the diagram fit on one screen without zooming? If not, split it.
- Is it stored as code (or in version control) so it can be updated?