Skip to main content
Documentation

Mermaid diagrams in Markdown: architecture diagrams that stay near the code

Mermaid makes diagrams reviewable as text. Use it for small, maintainable system views—not as a replacement for a carefully designed architecture document.

Thien Nguyen
By Thien Nguyen
Updated June 8, 2026 · 1 min read

Architecture diagrams rot when the source file lives in one tool and the service definition lives somewhere else. Mermaid's advantage is mundane and powerful: the diagram is text, so it can sit beside the Markdown and be reviewed in a pull request.

Short answer: use Mermaid for compact flowcharts, sequence diagrams, and dependency views where the source needs to change with the code. Keep labels short, show the boundaries that matter, and split diagrams when they require a zoom control to understand.

flowchart LR
  Browser --> API
  API --> Queue
  Queue --> Worker
  Worker --> Database
DiagramBest question it answers
FlowchartWhat calls what?
Sequence diagramIn what order do messages happen?
ER diagramWhich data entities relate?
State diagramWhat transitions are allowed?

A diagram should make a design decision easier to discuss. If it merely redraws every class and table, it is an expensive screenshot of complexity.

The documentation habit that works

Place a diagram at the decision boundary: the service README, the ADR, or the endpoint doc. Use stable nouns (API, billing worker) rather than deployment-specific hostnames. When an edge changes in code review, change the edge in the diagram in the same pull request.

Mermaid does not make architecture simple. It makes a small, useful view cheap enough to keep current.

Cover photo by Ivan S on Pexels.

References

Primary documentation and specifications checked when this article was last updated.

DocumentationArchitectureMermaid

Related articles

All articles