gen-uml
Overview
Generate a Mermaid diagram from existing code — architecture, flow, or sequence — and verify it reflects what the code actually does, not what it was supposed to do.
Steps
- Read the real code for the slice you're diagramming (entry points, modules, call/data flow). Diagram what exists.
- Pick the diagram type that answers the question being asked (below).
- Emit Mermaid.
- Match-check (required): walk the diagram against the code one node/edge at a time. Every box maps to a real module/function; every arrow to a real call/dependency. Drop or fix anything you can't point to in the source. A diagram that quietly diverges is worse than none.
Types & examples
Architecture (modules/dependencies):
graph TD
UI[UI] --> UC[Use cases]
UC --> SVC[Services]
SVC --> REPO[Repository]
REPO --> DB[(Store)]
Flow (a process / decision path):
flowchart TD
A[Receive task] --> B{Brownfield?}
B -- yes --> C[Explore code]
B -- no --> D[Brainstorm]
C --> D --> E[Plan]
Sequence (interaction over time):
sequenceDiagram
participant C as Client
participant R as Repo
participant DB as Store
C->>R: save(entity)
R->>DB: update(blob)
DB-->>R: version
R-->>C: ok
Output
The Mermaid block plus one line per diagram confirming the match-check passed (or listing what was corrected).