Skip to main content

mermaid-diagrams

Turn a technical concept into a text-defined diagram that lives in the repo, renders in pull requests, and stays maintainable. Docusaurus has Mermaid enabled (markdown.mermaid: true), so a mermaid code fence renders directly in any methodology doc, Design Doc, or PRD on the site β€” prefer it over attaching an image.

Pick the diagram type​

You want to showUseDeclaration
A process / decision tree / algorithmFlowchartflowchart TD
Interactions over time (API call, auth, RPC)SequencesequenceDiagram
Domain model / OO designClassclassDiagram
Database schema (tables, keys, relations)ERDerDiagram
System context / containers / componentsC4 or architectureC4Context / architecture-beta
Lifecycle / status machineStatestateDiagram-v2

Core syntax​

Every diagram: first line declares the type, then the definition. %% starts a comment. Unknown keywords break the diagram and bad params fail silently β€” keep it minimal and render to check.

Flowchart (directions: TD top-down, LR left-right):

Sequence β€” participant for components, actor for users; ->> call, -->> response:

ERD β€” PK/FK/UK; cardinality ||--o{ (one-to-many):

Class β€” visibility + public, - private, # protected:

State:

Where it fits in the platform​

  • Design Docs β€” sequence diagrams for the request/RPC flow, ERD for schema changes, C4/architecture for service boundaries. The diagram is the contract reviewers read.
  • Methodology / runbooks β€” flowcharts for a process; the Product↔R&D handoff pipeline diagram is one example.
  • Keep diagrams small and focused β€” one concern per diagram; split rather than cram. Version them as text alongside the code they describe.

Boundaries​

  • Renders on the docs site and in GitHub markdown β€” no image export needed; don't attach screenshots of diagrams.
  • For architecture decisions (not just pictures), the diagram supports an ADR / Design Doc β€” it doesn't replace the prose rationale.