Home / Market / mermaid diagrams

mermaid diagrams

Comprehensive guide for creating software diagrams using Mermaid syntax. Use when users need to create, visualize, or document software through diagrams including class diagrams (domain modeling, object-oriented design), sequence diagrams (application flows, API interactions, code execution), flowcharts (processes, algorithms, user journeys), entity relationship diagrams (database schemas), C4 architecture diagrams (system context, containers, components), state diagrams, git graphs, pie charts,

skill★ 34841918 dlskills.shMITInstall in CosmosUpstream Source

Documentation & Preview

Mermaid Diagrams Skill

A comprehensive guide for creating professional software diagrams using Mermaid's text-based syntax. This skill enables you to visualize system architecture, document code structure, model databases, and communicate technical concepts through diagrams.

Purpose

Transform complex technical concepts into clear, maintainable diagrams that can be version-controlled alongside your code. Mermaid diagrams are rendered from simple text definitions, making them easy to update, review in pull requests, and maintain over time.

When to Use This Skill

Use this skill when you need to:

Trigger Phrases

The skill activates when you mention:

How It Works

  1. Choose the right diagram type based on what you want to communicate
  2. Start with core elements - entities, actors, or components
  3. Add relationships - connections, flows, interactions
  4. Refine incrementally - add details, styling, notes
  5. Export or embed - use in documentation, PRs, wikis

Mermaid syntax is intuitive and follows a consistent pattern across all diagram types:

diagramType
  definition content

Key Features

9 Diagram Types Supported

  1. Class Diagrams - Domain models, OOP design, entity relationships
  2. Sequence Diagrams - API flows, user interactions, temporal sequences
  3. Flowcharts - User journeys, processes, decision logic, pipelines
  4. Entity Relationship Diagrams - Database schemas, table relationships
  5. C4 Architecture Diagrams - System context, containers, components
  6. State Diagrams - State machines, lifecycle states
  7. Git Graphs - Branching strategies, version control flows
  8. Gantt Charts - Project timelines, scheduling
  9. Pie/Bar Charts - Data visualization, metrics

Advanced Capabilities

Integration Support

Usage Examples

Example 1: Document a Domain Model

When: You're designing a video streaming platform and need to model core entities.

classDiagram
    Title -- Genre
    Title *-- Season
    Title *-- Review
    User --> Review : creates

    class Title {
        +string name
        +int releaseYear
        +play()
    }

    class Genre {
        +string name
        +getTopTitles()
    }

Example 2: Explain an API Authentication Flow

When: You need to document how login works for frontend developers.

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

Example 3: Map a User Journey

When: You're planning a feature and need to visualize the user flow.

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

Example 4: Design a Database Schema

When: You're planning table relationships for a new feature.

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
    }

Example 5: Visualize System Architecture (C4)

When: You need to show how systems and external services interact.

C4Context
    title System Context Diagram for E-commerce Platform

    Person(customer, "Customer", "A user browsing and purchasing products")
    System(webApp, "Web Application", "Provides product catalog and checkout")
    System_Ext(payment, "Payment Gateway", "Processes payments")
    System_Ext(email, "Email Service", "Sends order confirmations")

    Rel(customer, webApp, "Browses products, places orders")
    Rel(webApp, payment, "Processes payments", "HTTPS")
    Rel(webApp, email, "Sends notifications", "SMTP")

Getting Started

  1. Identify what you need to communicate - Architecture? Flow? Data model?
  2. Choose the appropriate diagram type - See "Diagram Type Selection Guide" in SKILL.md
  3. Start simple - Add core entities/components first
  4. Add relationships - Connect elements with appropriate connectors
  5. Refine and style - Add details, notes, and custom theming
  6. Validate - Test in Mermaid Live Editor
  7. Embed or export - Use in Markdown, export as image, or integrate

Detailed References

For comprehensive syntax and advanced features, see:

Best Practices

  1. Start simple, iterate - Begin with core elements, add complexity gradually
  2. One diagram, one concept - Keep diagrams focused and split large views
  3. Use meaningful names - Clear labels make diagrams self-documenting
  4. Comment liberally - Use %% to explain non-obvious relationships
  5. Version control - Store .mmd files with code, update as system evolves
  6. Add context - Include titles and notes explaining diagram purpose
  7. Validate syntax - Test in Mermaid Live before committing
  8. Keep it readable - Don't overcrowd; split into multiple diagrams if needed

Common Use Cases

Tips for Success

Tools and Resources

Support

For questions, syntax help, or advanced features, refer to: