askill
diagram-patterns

diagram-patternsSafety 95Repository

Mermaid diagram templates for C4 Context, C4 Container, data flow, agent flow, deployment, and sequence diagrams. Use when generating architecture diagrams.

0 stars
1.2k downloads
Updated 2/14/2026

Package Files

Loading files...
SKILL.md

Diagram Patterns

Guidelines and templates for generating consistent, readable architecture diagrams using Mermaid syntax. All diagrams in this plugin use Mermaid β€” never ASCII art.


Diagram Types

DiagramWhen to UseMermaid Type
C4 ContextShow the system in relation to users and external systemsgraph TB
C4 ContainerShow internal containers (frontends, services, databases)graph TB
Data FlowShow how data moves through the systemgraph LR
Agent FlowShow AI agent orchestration and tool usagegraph TD
DeploymentShow where components rungraph TB
SequenceShow interaction between components over timesequenceDiagram

Color Conventions

Use consistent colors across all diagrams:

Component TypeColorMermaid Style
User / ActorGreystyle ... fill:#e8e8e8,stroke:#999
FrontendBluestyle ... fill:#4a90d9,stroke:#2c5ea0,color:#fff
Backend ServiceGreenstyle ... fill:#5cb85c,stroke:#3d8b3d,color:#fff
DatabaseOrangestyle ... fill:#f0ad4e,stroke:#c77c00,color:#fff
External ServicePurplestyle ... fill:#9b59b6,stroke:#6c3483,color:#fff
AI Agent / LLMRed/Pinkstyle ... fill:#e74c3c,stroke:#c0392b,color:#fff
Message QueueTealstyle ... fill:#1abc9c,stroke:#16a085,color:#fff

C4 Context Diagram

Shows the system as a single box, with users and external systems around it.

graph TB
    User["πŸ‘€ End User<br/><i>Uses the application</i>"]
    Admin["πŸ‘€ Admin<br/><i>Manages content and users</i>"]

    System["🏒 System Name<br/><i>Brief description of what<br/>the system does</i>"]

    Email["πŸ“§ Email Service<br/><i>SendGrid / Resend</i>"]
    Payment["πŸ’³ Payment Provider<br/><i>Stripe</i>"]
    LLM["πŸ€– LLM Provider<br/><i>Anthropic Claude</i>"]

    User -->|"Uses"| System
    Admin -->|"Manages"| System
    System -->|"Sends emails via"| Email
    System -->|"Processes payments via"| Payment
    System -->|"Generates content via"| LLM

    style System fill:#4a90d9,stroke:#2c5ea0,color:#fff
    style User fill:#e8e8e8,stroke:#999
    style Admin fill:#e8e8e8,stroke:#999
    style Email fill:#9b59b6,stroke:#6c3483,color:#fff
    style Payment fill:#9b59b6,stroke:#6c3483,color:#fff
    style LLM fill:#e74c3c,stroke:#c0392b,color:#fff

C4 Container Diagram

Shows the internal structure: frontends, services, databases, and their connections.

graph TB
    subgraph "Frontend"
        WebApp["🌐 Web App<br/><i>Next.js</i>"]
    end

    subgraph "Backend"
        API["βš™οΈ API Server<br/><i>Node.js / Express</i>"]
        Worker["⏰ Background Worker<br/><i>BullMQ</i>"]
    end

    subgraph "Data"
        DB[("πŸ—„οΈ PostgreSQL<br/><i>Primary database</i>")]
        Cache[("⚑ Redis<br/><i>Cache + queues</i>")]
    end

    subgraph "External"
        Stripe["πŸ’³ Stripe"]
        Resend["πŸ“§ Resend"]
        Claude["πŸ€– Claude API"]
    end

    WebApp -->|"REST API"| API
    API -->|"Reads/writes"| DB
    API -->|"Cache + queue"| Cache
    Worker -->|"Processes jobs from"| Cache
    Worker -->|"Reads/writes"| DB
    API -->|"Payments"| Stripe
    Worker -->|"Sends emails"| Resend
    API -->|"LLM calls"| Claude

    style WebApp fill:#4a90d9,stroke:#2c5ea0,color:#fff
    style API fill:#5cb85c,stroke:#3d8b3d,color:#fff
    style Worker fill:#5cb85c,stroke:#3d8b3d,color:#fff
    style DB fill:#f0ad4e,stroke:#c77c00,color:#fff
    style Cache fill:#f0ad4e,stroke:#c77c00,color:#fff
    style Stripe fill:#9b59b6,stroke:#6c3483,color:#fff
    style Resend fill:#9b59b6,stroke:#6c3483,color:#fff
    style Claude fill:#e74c3c,stroke:#c0392b,color:#fff

Agent Flow Diagram

Shows how an AI agent processes requests, uses tools, and returns results.

graph TD
    Input["πŸ“₯ User Message"]
    Router{"🧭 Intent Router"}
    Agent1["πŸ€– Agent: Researcher<br/><i>Gathers information</i>"]
    Agent2["πŸ€– Agent: Writer<br/><i>Generates content</i>"]

    Tool1["πŸ” Web Search"]
    Tool2["πŸ—„οΈ Knowledge Base"]
    Tool3["πŸ“ Content Generator"]

    Guardrails{"πŸ›‘οΈ Guardrails Check"}
    Output["πŸ“€ Response"]

    Input --> Router
    Router -->|"Research query"| Agent1
    Router -->|"Content request"| Agent2

    Agent1 --> Tool1
    Agent1 --> Tool2
    Agent1 --> Guardrails

    Agent2 --> Tool3
    Agent2 --> Tool2
    Agent2 --> Guardrails

    Guardrails -->|"Pass"| Output
    Guardrails -->|"Fail"| Agent1

    style Input fill:#e8e8e8,stroke:#999
    style Router fill:#f0ad4e,stroke:#c77c00,color:#fff
    style Agent1 fill:#e74c3c,stroke:#c0392b,color:#fff
    style Agent2 fill:#e74c3c,stroke:#c0392b,color:#fff
    style Tool1 fill:#5cb85c,stroke:#3d8b3d,color:#fff
    style Tool2 fill:#5cb85c,stroke:#3d8b3d,color:#fff
    style Tool3 fill:#5cb85c,stroke:#3d8b3d,color:#fff
    style Guardrails fill:#1abc9c,stroke:#16a085,color:#fff
    style Output fill:#e8e8e8,stroke:#999

Data Flow Diagram

Shows how data moves through the system from input to storage to output.

graph LR
    User["πŸ‘€ User"] -->|"Submits form"| WebApp
    WebApp["🌐 Web App"] -->|"POST /api/data"| API
    API["βš™οΈ API Server"] -->|"Validate + transform"| DB
    DB[("πŸ—„οΈ Database")] -->|"Change event"| Queue
    Queue["πŸ“¬ Message Queue"] -->|"Process"| Worker
    Worker["⏰ Worker"] -->|"Generate"| LLM
    LLM["πŸ€– LLM"] -->|"Result"| Worker
    Worker -->|"Store result"| DB
    Worker -->|"Notify"| Email["πŸ“§ Email"]

    style User fill:#e8e8e8,stroke:#999
    style WebApp fill:#4a90d9,stroke:#2c5ea0,color:#fff
    style API fill:#5cb85c,stroke:#3d8b3d,color:#fff
    style DB fill:#f0ad4e,stroke:#c77c00,color:#fff
    style Queue fill:#1abc9c,stroke:#16a085,color:#fff
    style Worker fill:#5cb85c,stroke:#3d8b3d,color:#fff
    style LLM fill:#e74c3c,stroke:#c0392b,color:#fff
    style Email fill:#9b59b6,stroke:#6c3483,color:#fff

Deployment Diagram

Shows where each component is deployed.

graph TB
    subgraph "Vercel"
        Frontend["🌐 Next.js App"]
        Serverless["⚑ API Routes"]
    end

    subgraph "Railway"
        API["βš™οΈ API Server"]
        Worker["⏰ Background Worker"]
    end

    subgraph "Managed Services"
        Supabase[("πŸ—„οΈ Supabase<br/>PostgreSQL + Auth")]
        Upstash[("⚑ Upstash Redis")]
    end

    subgraph "Third Party"
        Stripe["πŸ’³ Stripe"]
        Claude["πŸ€– Claude API"]
        Resend["πŸ“§ Resend"]
    end

    Frontend --> Serverless
    Serverless --> API
    API --> Supabase
    API --> Upstash
    API --> Stripe
    API --> Claude
    Worker --> Upstash
    Worker --> Supabase
    Worker --> Resend

    style Frontend fill:#4a90d9,stroke:#2c5ea0,color:#fff
    style Serverless fill:#4a90d9,stroke:#2c5ea0,color:#fff
    style API fill:#5cb85c,stroke:#3d8b3d,color:#fff
    style Worker fill:#5cb85c,stroke:#3d8b3d,color:#fff
    style Supabase fill:#f0ad4e,stroke:#c77c00,color:#fff
    style Upstash fill:#f0ad4e,stroke:#c77c00,color:#fff
    style Stripe fill:#9b59b6,stroke:#6c3483,color:#fff
    style Claude fill:#e74c3c,stroke:#c0392b,color:#fff
    style Resend fill:#9b59b6,stroke:#6c3483,color:#fff

Sequence Diagram

Shows time-ordered interactions between components.

sequenceDiagram
    actor User
    participant Web as Web App
    participant API as API Server
    participant DB as Database
    participant LLM as Claude API

    User->>Web: Submit question
    Web->>API: POST /api/chat
    API->>DB: Fetch conversation history
    DB-->>API: History
    API->>LLM: Send prompt + history
    LLM-->>API: Stream response
    API-->>Web: SSE stream
    Web-->>User: Display streaming response
    API->>DB: Save conversation

Diagram Rules

  1. Always include a legend if the diagram has more than 5 nodes β€” use the color conventions above
  2. Label every arrow β€” connections without labels are meaningless
  3. Use subgraphs to group related components (Frontend, Backend, Data, External)
  4. Keep it readable β€” max 12-15 nodes per diagram. If more, split into multiple diagrams
  5. Use icons in node labels for visual scanning (🌐 web, βš™οΈ service, πŸ—„οΈ database, πŸ€– AI, πŸ’³ payment, πŸ“§ email)
  6. Show direction β€” top-to-bottom for hierarchy, left-to-right for data flow
  7. Include technology names β€” "Next.js" not just "Web App", "PostgreSQL" not just "Database"

Install

Download ZIP
Requires askill CLI v1.0+β–Ά

AI Quality Score

91/100Analyzed yesterday

High-quality diagram reference skill with comprehensive Mermaid templates for 6 diagram types (C4 Context, C4 Container, Agent Flow, Data Flow, Deployment, Sequence). Includes exact color codes, practical rules, and well-structured examples. Very actionable and reusable across any architecture documentation needs. Only minor gap is lack of advanced patterns or troubleshooting guidance.

95
90
95
85
90

Metadata

Licenseunknown
Version-
Updated2/14/2026
Publishernavraj007in

Tags

apidatabasellmpromptingsecurity