Mermaid Generator
The Mermaid Generator is Phase 2 of the Omni Architect pipeline. It automatically generates multiple types of Mermaid diagrams from the parsed PRD structure, creating visual representations of product logic, data models, user interactions, and system architecture.Purpose
Transforms structured PRD data into executable Mermaid diagram code that visualizes:- Business Flows as flowcharts
- User Interactions as sequence diagrams
- Data Models as entity-relationship diagrams
- Feature States as state diagrams
- System Architecture as C4 Context diagrams
- User Journeys as journey maps
- Project Timelines as Gantt charts
Inputs
The structured PRD output from the PRD Parser (Phase 1). Must contain features, entities, flows, and user stories.
Array of diagram types to generate. Supported values:
flowchart- Business process flowssequence- Actor-system interaction sequenceserDiagram- Entity-relationship data modelsstateDiagram- State machines for featuresC4Context- System context architecturejourney- User journey mapsgantt- Project timelines
Language for diagram labels and annotations. Supports
pt-BR, en-US, es-ES, etc.Outputs
Array of generated diagram objects, each containing:Structure:
Diagram Type Mappings
The generator automatically selects appropriate diagram types based on PRD content: | PRD Element | Mermaid Type | Condition | |-------------|--------------|-----------|| |flows | flowchart TD | Always generated when flows exist |
| user_stories + entities | sequenceDiagram | When actor-system interactions are present |
| entities + relationships | erDiagram | When >= 2 entities with relationships exist |
| features with lifecycle states | stateDiagram-v2 | When features have state transitions |
| system_overview | C4Context | When PRD mentions external systems |
| personas + journeys | journey | When user personas are defined |
| dependencies + timeline | gantt | When feature timeline is specified |
Generation Rules
1. Syntax Validation
All generated Mermaid code is validated using a parser check before output. Invalid syntax triggers automatic correction with up to 3 retry attempts.2. Localization
Labels, annotations, and node names are automatically translated to the configuredlocale:
3. Node Limits
Diagrams are limited to 50 nodes maximum. If a flow exceeds this limit, it’s automatically split into sub-diagrams with an index diagram for navigation.4. Traceability Comments
Feature and story IDs are embedded as comments for traceability:5. Coverage Calculation
Each diagram includes acoverage_pct indicating what percentage of PRD elements are represented:
Example Outputs
Flowchart: Checkout Process
Metadata:Sequence Diagram: User Registration
Metadata:ER Diagram: E-Commerce Domain
Metadata:State Diagram: Order Lifecycle
Metadata:Best Practices
Provide Complete PRD Data
The quality of generated diagrams depends on PRD completeness. Ensure your PRD includes:- Clear flow descriptions with steps
- Well-defined entities with attributes
- User stories with actors and actions
- Feature dependencies and states
Request Multiple Diagram Types
Different diagrams reveal different aspects of your product:Review Coverage Percentages
Low coverage indicates missing diagram types or incomplete PRD sections. Aim for >85% coverage.Use Diagrams for Validation
These diagrams are meant for logic validation before design. Share with stakeholders to catch gaps early.Error Handling
| Scenario | Behavior |
|---|---|
| Invalid Mermaid syntax | Auto-correction with up to 3 retries, then warning |
| PRD missing required sections | Skips affected diagram types, generates what’s possible |
| Diagram exceeds 50 nodes | Auto-splits into sub-diagrams with index |
| Unsupported diagram type | Warning logged, type skipped |
| Entity relationship cycles | Detected and resolved with proper edge directions |