Problem
Diagrams drawn in GUI tools drift from the system, live in separate files, and cannot be reviewed in pull requests. Nobody dares update them.
Also known as: diagram-as-code, text-based-diagrams
Describe architecture diagrams as text kept in version control so they are reviewable, diffable, and rendered automatically.
Diagrams drawn in GUI tools drift from the system, live in separate files, and cannot be reviewed in pull requests. Nobody dares update them.
Mermaid is a text language for drawing diagrams. Because the source is plain text, it lives in the same repository as the code and goes through the same review process. A reviewer sees exactly which service or arrow was added, which is impossible with a binary image.
Place the definition in a fenced block labeled mermaid. GitHub and many docs tools render it inline.
sequenceDiagram
participant C as Client
participant G as API Gateway
participant O as Order Service
participant P as Payment Service
C->>G: POST /orders
G->>O: create order
O->>P: authorize payment
P-->>O: authorized
O-->>C: 201 Created
Choose the type by the question being answered: flowcharts for components and dependencies, sequence diagrams for request flows, state diagrams for lifecycles. Pair the diagrams with a short caption stating scope and abstraction level, for example a C4 container view.
Low: free tooling
Low: little upkeep
Low: small syntax to learn
One giant diagram mixing abstraction levels
Renderer version mismatch breaks display
Diagram source never updated with the code change