Mermaid Diagram
Generate proper, well-structured Mermaid diagrams for visual documentation and design presentations.
Diagram Selection
| Need | Diagram | Reference |
|---|---|---|
| Process flow, decisions | Flowchart | flowchart.md |
| API/service interactions | Sequence | sequence.md |
| Object-oriented design | Class | class.md |
| Database schema | ER Diagram | er.md |
| State machines, lifecycles | State | state.md |
| Software architecture (C4) | C4 | c4.md |
| Cloud/infrastructure | Architecture | architecture.md |
| Brainstorming, concepts | Mindmap | mindmap.md |
| Timelines, charts, git | Other | other-diagrams.md |
Quick Examples
Flowchart
mermaid
flowchart TD
A[Start] --> B{Decision}
B -->|Yes| C[Action]
B -->|No| D[Other]
C --> E[End]
D --> E
Sequence
mermaid
sequenceDiagram
Client->>+API: Request
API->>DB: Query
DB-->>API: Data
API-->>-Client: Response
Class
mermaid
classDiagram
class Animal {
+String name
+makeSound()
}
Animal <|-- Dog
Animal <|-- Cat
ER
mermaid
erDiagram
USER ||--o{ ORDER : places
ORDER ||--|{ ITEM : contains
Best Practices
- •Choose the right diagram - Match diagram type to what you're representing
- •Keep it readable - Limit nodes, use clear labels, avoid crossing lines
- •Use direction -
LRfor wide diagrams,TDfor tall ones - •Group related items - Use subgraphs, boundaries, or namespaces
- •Add context - Use notes and labels to explain non-obvious elements
- •Style sparingly - Only highlight what needs attention
Output Format
Always wrap diagrams in fenced code blocks:
code
```mermaid
flowchart LR
A --> B
```
Consult the appropriate reference file for detailed syntax before generating complex diagrams.