skills/el-feo/ai-context/mermaid-diagrams

mermaid-diagrams

Installation
SKILL.md

Mermaid Diagramming

Create professional software diagrams using Mermaid's text-based syntax. Mermaid renders diagrams from simple text definitions, making diagrams version-controllable, easy to update, and maintainable alongside code.

Core Syntax Structure

All Mermaid diagrams follow this pattern:

diagramType
  definition content

Key principles:

  • First line declares diagram type (e.g., classDiagram, sequenceDiagram, flowchart)
  • Use %% for comments
  • Line breaks and indentation improve readability but aren't required
  • Unknown words break diagrams; parameters fail silently

Diagram Type Selection Guide

Choose the right diagram type:

  1. Class Diagrams - Domain modeling, OOP design, entity relationships

    • Domain-driven design documentation
    • Object-oriented class structures
    • Entity relationships and dependencies
  2. Sequence Diagrams - Temporal interactions, message flows

    • API request/response flows
    • User authentication flows
    • System component interactions
    • Method call sequences
  3. Flowcharts - Processes, algorithms, decision trees

    • User journeys and workflows
    • Business processes
    • Algorithm logic
    • Deployment pipelines
  4. Entity Relationship Diagrams (ERD) - Database schemas

    • Table relationships
    • Data modeling
    • Schema design
  5. C4 Diagrams - Software architecture at multiple levels

    • System Context (systems and users)
    • Container (applications, databases, services)
    • Component (internal structure)
    • Code (class/interface level)
  6. State Diagrams - State machines, lifecycle states

  7. Git Graphs - Version control branching strategies

  8. Gantt Charts - Project timelines, scheduling

  9. Pie/Bar Charts - Data visualization

Quick Start Examples

Class Diagram (Domain Model)

classDiagram
    Title -- Genre
    Title *-- Season
    Title *-- Review
    User --> Review : creates
    
    class Title {
        +string name
        +int releaseYear
        +play()
    }
    
    class Genre {
        +string name
        +getTopTitles()
    }

Sequence Diagram (API Flow)

sequenceDiagram
    participant User
    participant API
    participant Database
    
    User->>API: POST /login
    API->>Database: Query credentials
    Database-->>API: Return user data
    alt Valid credentials
        API-->>User: 200 OK + JWT token
    else Invalid credentials
        API-->>User: 401 Unauthorized
    end

Flowchart (User Journey)

flowchart TD
    Start([User visits site]) --> Auth{Authenticated?}
    Auth -->|No| Login[Show login page]
    Auth -->|Yes| Dashboard[Show dashboard]
    Login --> Creds[Enter credentials]
    Creds --> Validate{Valid?}
    Validate -->|Yes| Dashboard
    Validate -->|No| Error[Show error]
    Error --> Login

ERD (Database Schema)

erDiagram
    USER ||--o{ ORDER : places
    ORDER ||--|{ LINE_ITEM : contains
    PRODUCT ||--o{ LINE_ITEM : includes
    
    USER {
        int id PK
        string email UK
        string name
        datetime created_at
    }
    
    ORDER {
        int id PK
        int user_id FK
        decimal total
        datetime created_at
    }

Detailed References

For in-depth guidance on specific diagram types, see:

Important Notes

  • Avoid {} in comments — they break diagrams. Use proper escape sequences for special characters.
  • Unknown words and misspellings break diagrams silently; parameters fail silently.
  • Use %% for comments.
  • For theming, styling, and layout configuration, see references/advanced-features.md.
  • Export with CLI: npm install -g @mermaid-js/mermaid-cli then mmdc -i input.mmd -o output.png
Weekly Installs
23
GitHub Stars
9
First Seen
Jan 24, 2026