一键导入
architecture-diagram-with-ai
Generate architecture diagrams, flowcharts, and system designs using Mermaid, Excalidraw, or draw.io via AI prompts
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Generate architecture diagrams, flowcharts, and system designs using Mermaid, Excalidraw, or draw.io via AI prompts
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
| name | architecture-diagram-with-ai |
| description | Generate architecture diagrams, flowcharts, and system designs using Mermaid, Excalidraw, or draw.io via AI prompts |
| tags | ["architecture","mermaid","diagrams","excalidraw","drawio","system-design"] |
| related_skills | ["mermaid-in-wiki-pages","architecture-diagram"] |
A practical guide for AI agents to help users create, refine, and export architecture diagrams using Mermaid, Excalidraw, draw.io, and MCP-integrated tools.
Load this skill when the user:
mermaid-mcp, excalidraw-mcp, or asks to render a diagram directlyFollow this process for every diagram request:
Understand what the user wants to visualize. Ask (if not clear):
Use the decision tree in Section 3 to pick the right tool and diagram type.
Produce a complete, valid diagram in the chosen syntax. Always:
Render the diagram (or show the code block) and briefly explain:
Offer to refine: add components, change layout, adjust style, export to another format.
flowchart TD
A([User Request]) --> B{Intent Clear?}
B -- No --> C[Ask Clarifying Questions]
C --> B
B -- Yes --> D{Select Tool}
D --> E[Mermaid]
D --> F[Excalidraw]
D --> G[draw.io / diagrams.net]
E & F & G --> H[Generate Initial Diagram]
H --> I[Present & Explain]
I --> J{User Satisfied?}
J -- No --> K[Collect Feedback]
K --> H
J -- Yes --> L([Done ✓])
flowchart TD
Start([What does the user need?]) --> Q1{Embed in Markdown\nor Wiki?}
Q1 -- Yes --> Mermaid[🧜 Mermaid]
Q1 -- No --> Q2{Need hand-drawn\nor collaborative feel?}
Q2 -- Yes --> Excalidraw[✏️ Excalidraw]
Q2 -- No --> Q3{Complex diagrams\nor UML export needed?}
Q3 -- Yes --> DrawIO[📐 draw.io / diagrams.net]
Q3 -- No --> Q4{Quick render\nvia MCP tool?}
Q4 -- Yes --> MCP[🔌 MCP Server]
Q4 -- No --> Mermaid
🧜 Mermaid
mermaid-mcp-server✏️ Excalidraw
.excalidraw JSON, PNG, SVGexcalidraw-mcp (community)📐 draw.io / diagrams.net
.drawio XML, PDF, PNG, SVG🌿 PlantUML
Which diagram type for which use case:
graph TDsequenceDiagramerDiagramclassDiagramflowchart TDganttstateDiagram-v2journeygitGraphgraph LR with icons or draw.io AWS stencilssequenceDiagramgraph TDerDiagramgraph LR (Mermaid) or draw.ioflowchart TDclassDiagramstateDiagram-v2Use these templates when generating Mermaid diagrams:
System Architecture prompt:
Generate a Mermaid `graph TD` diagram for a [system name] with the following components:
- [Component A]: [description]
- [Component B]: [description]
Show data flows between components with labeled arrows.
Group related components in subgraphs.
Sequence Diagram prompt:
Generate a Mermaid sequenceDiagram showing the flow of [action, e.g., user login].
Participants: [User, Frontend, Auth Service, Database]
Steps:
1. [step 1]
2. [step 2]
Include alt/else blocks for error cases.
ER Diagram prompt:
Generate a Mermaid erDiagram for a [domain, e.g., e-commerce] system.
Entities: [User, Order, Product, Payment]
Include all relationships with correct cardinality.
["label text"] for spaces/special chars--> plain arrow-- label --> labeled arrow==> thick arrow-.-> dotted arrow--x cross/blockedsubgraph ServiceLayer["Service Layer"]
A --> B
end
[rect] rectangle(rounded) rounded rect{diamond} decision/rhombus([stadium]) stadium/pill[[subroutine]] subroutine[(cylinder)] database cylindergraph TD
Client(["🌐 Client Browser"]) --> Gateway["API Gateway"]
Gateway --> AuthSvc["Auth Service"]
Gateway --> UserSvc["User Service"]
Gateway --> OrderSvc["Order Service"]
AuthSvc --> AuthDB[(Auth DB\nPostgres)]
UserSvc --> UserDB[(User DB\nMongoDB)]
OrderSvc --> OrderDB[(Order DB\nPostgres)]
OrderSvc --> Queue["Message Queue\nRabbitMQ"]
Queue --> NotifSvc["Notification Service"]
NotifSvc --> Email["📧 Email Provider"]
NotifSvc --> SMS["📱 SMS Provider"]
subgraph DataLayer["Data Layer"]
AuthDB
UserDB
OrderDB
end
subgraph Messaging["Async Messaging"]
Queue
NotifSvc
end
sequenceDiagram
autonumber
actor User
participant FE as Frontend
participant Auth as Auth Service
participant DB as Database
User->>FE: Enter credentials
FE->>Auth: POST /login {email, password}
Auth->>DB: Query user by email
DB-->>Auth: Return user record
Auth->>Auth: Validate password hash
alt Valid credentials
Auth-->>FE: 200 OK + JWT token
FE-->>User: Redirect to dashboard
else Invalid credentials
Auth-->>FE: 401 Unauthorized
FE-->>User: Show error message
end
erDiagram
USER ||--o{ ORDER : "places"
ORDER ||--|{ LINE_ITEM : "contains"
PRODUCT ||--o{ LINE_ITEM : "included in"
ORDER ||--|| PAYMENT : "paid via"
USER {
int id PK
string email
string name
datetime created_at
}
ORDER {
int id PK
int user_id FK
string status
decimal total
}
PRODUCT {
int id PK
string name
decimal price
}
1. mermaid-mcp-server
render_mermaid, validate_mermaidnpm install -g mermaid-mcp-server2. excalidraw-mcp (community)
create_excalidraw, export_excalidraw3. diagrams-mcp (community)
diagrams library for cloud architecture (AWS, GCP, Azure icons)generate_diagram# ~/.hermes/config.yaml
mcp:
servers:
mermaid:
command: npx
args: ["-y", "mermaid-mcp-server"]
env: {}
excalidraw:
command: npx
args: ["-y", "excalidraw-mcp-server"]
env: {}
Install on-demand via npx (no global install needed):
# Verify mermaid-mcp-server is available
npx -y mermaid-mcp-server --help
When MCP tools are available, prefer them for rendering:
# Step 1: Validate Mermaid syntax
result = mcp__mermaid__validate_mermaid(
code="graph TD\n A[Client] --> B[Server]"
)
# Returns: { valid: true } or { valid: false, error: "Parse error on line 2..." }
# Step 2: Render to PNG
result = mcp__mermaid__render_mermaid(
code="graph TD\n A[Client] --> B[Server]",
format="png", # or "svg"
theme="default", # or "dark", "forest", "neutral"
background="white"
)
# Returns: { file_path: "/tmp/diagram.png" } or base64 image data
Agent workflow with MCP:
validate_mermaid — fix any syntax errors returnedrender_mermaid — get rendered image file path or base64Fallback when MCP is unavailable:
```mermaid ``` code blockAfter delivering an initial diagram, suggest:
"Would you like me to:
- Add more detail (protocols, ports, data formats, technologies)?
- Simplify (remove noise, focus on one layer or service)?
- Change layout direction (left-to-right vs top-down)?
- Add styling/colors to distinguish component types?
- Export to a different format (draw.io XML, Excalidraw JSON)?"
Add color with style:
graph TD
A[Service A] --> B[Service B]
B --> C[(Database)]
style A fill:#4CAF50,color:#fff,stroke:#388E3C
style B fill:#2196F3,color:#fff,stroke:#1565C0
style C fill:#FF9800,color:#fff,stroke:#E65100
Use classDef for consistent theming:
graph TD
classDef service fill:#2196F3,color:#fff,rx:8,ry:8
classDef database fill:#FF9800,color:#fff
classDef external fill:#9C27B0,color:#fff,stroke-dasharray:5 5
A[Auth Service]:::service
B[(User DB)]:::database
C[Stripe API]:::external
A --> B
A --> C
Add clickable links (for HTML rendering):
graph TD
A[Service A]
click A href "https://docs.example.com/service-a" "Open docs" _blank
When the user says "add X" or "change Y":
❌ Wrong — parentheses break parser:
graph TD
A[My Node (with parens)] --> B
✅ Fixed — wrap in quotes:
graph TD
A["My Node (with parens)"] --> B
❌ Wrong — same ID with different labels:
graph TD
DB[(Database)] --> App
DB[(Cache)] --> Worker
✅ Fixed — use unique IDs:
graph TD
PrimaryDB[(Primary DB)] --> App
CacheDB[(Cache DB)] --> Worker
❌ Wrong:
graph TD
subgraph Backend
Backend --> DB
end
✅ Fixed — use quoted subgraph label:
graph TD
subgraph BackendLayer["Backend"]
API --> DB
end
❌ Wrong — implicit order causes confusion:
sequenceDiagram
B->>A: Response
A->>B: Request
✅ Fixed — declare participants explicitly:
sequenceDiagram
participant A as Client
participant B as Server
A->>B: Request
B-->>A: Response
❌ Wrong:
erDiagram
USER -> ORDER
✅ Fixed:
erDiagram
USER ||--o{ ORDER : "places"
Cardinality notation:
|| exactly oneo| zero or one}| one or more (right side)}o zero or more (right side)✅ Fix — always wrap emoji labels in quotes:
graph TD
A["🌐 Web Client"] --> B["🔒 Auth Service"]
✅ Fix — use <br/> for line breaks within labels:
graph TD
A["Payment<br/>Processing<br/>Service"] --> B
❌ Wrong:
A ->|label| B
✅ Fixed:
A -->|label| B
Or the long form:
A -- label --> B
Option 1 — Mermaid Live Editor (fastest, no setup)
Option 2 — Via MCP Tool (when configured)
mcp__mermaid__validate_mermaid(code="<your mermaid code here>")
# Returns: { valid: true } or { valid: false, error: "Parse error on line N: ..." }
Option 3 — GitHub / GitLab
.md file — GitHub renders Mermaid nativelyOption 4 — VS Code
.md file → Ctrl+Shift+V (or Cmd+Shift+V on Mac) to previewOption 5 — Mermaid CLI
# Install
npm install -g @mermaid-js/mermaid-cli
# Render to PNG
mmdc -i diagram.mmd -o diagram.png
# Render to SVG with dark theme
mmdc -i diagram.mmd -o diagram.svg --theme dark
# Render from stdin
echo "graph TD; A-->B" | mmdc -i /dev/stdin -o out.png
Before delivering any diagram, confirm:
(), [], {}, /, &) are quotedDIAGRAM TYPES (Mermaid):
flowchart TD/LR General flow, architecture, pipelines
sequenceDiagram API calls, service interactions, auth flows
erDiagram Database schemas, data models
classDiagram OOP class hierarchy, code structure
stateDiagram-v2 State machines, lifecycle diagrams
gantt Project timelines, sprint planning
gitGraph Git branching strategies
journey User experience flows
ARROW TYPES (flowchart):
--> Plain arrow
-- x --> Labeled arrow
==> Thick arrow
-.-> Dotted arrow
--x Cross/blocked (no flow)
CARDINALITY (erDiagram):
||--|| one-to-one
||--o{ one-to-zero-or-many
||--|{ one-to-one-or-many
MCP SERVERS:
mermaid-mcp-server https://github.com/peng-shawn/mermaid-mcp-server
excalidraw-mcp community npm package
ONLINE TOOLS:
https://mermaid.live Mermaid live editor + validator
https://excalidraw.com Excalidraw whiteboard
https://app.diagrams.net draw.io / diagrams.net editor