project-diagrams
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseProject Diagrams and Architecture Visualizations
项目图与架构可视化
Overview
概述
Project diagrams transform complex software architectures and system designs into clear visual representations. This skill offers two diagram generation approaches:
| Approach | Best For | Output |
|---|---|---|
| Nano Banana Pro AI | Publication-quality visuals, presentations, complex custom diagrams | PNG images |
| Mermaid | Version-controlled docs, GitHub markdown, editable diagrams | SVG/PNG from code |
项目图可将复杂的软件架构和系统设计转化为清晰的可视化表示。本技能提供两种图表生成方式:
| 方式 | 适用场景 | 输出格式 |
|---|---|---|
| Nano Banana Pro AI | 出版级视觉效果、演示文稿、复杂自定义图表 | PNG图片 |
| Mermaid | 版本控制文档、GitHub Markdown、可编辑图表 | 代码生成的SVG/PNG |
Choosing Your Approach
选择合适的方式
Use Nano Banana Pro AI when:
选择Nano Banana Pro AI的场景:
- You need visually polished, publication-ready diagrams
- Creating custom visualizations that don't fit standard templates
- Diagrams for presentations, proposals, or client deliverables
- Complex architectural diagrams with custom styling
- 你需要视觉效果精美、可直接用于出版的图表
- 创建不符合标准模板的自定义可视化内容
- 用于演示文稿、提案或客户交付物的图表
- 带有自定义样式的复杂架构图
Use Mermaid when:
选择Mermaid的场景:
- Diagrams need to be version-controlled in git (text diffs)
- Embedding directly in GitHub/GitLab markdown
- You need to edit and iterate quickly on diagram structure
- Standardized diagram types (flowcharts, sequence, C4, ERD, Gantt)
- Collaborative documentation where others may edit
- 图表需要在Git中进行版本控制(支持文本差异对比)
- 直接嵌入到GitHub/GitLab的Markdown中
- 你需要快速编辑和迭代图表结构
- 标准化图表类型(流程图、时序图、C4图、ERD、甘特图)
- 需要多人协作编辑的文档
Option 1: Nano Banana Pro AI (Recommended for Visuals)
选项1:Nano Banana Pro AI(推荐用于追求视觉效果的场景)
This approach uses Nano Banana Pro AI for diagram generation with Gemini 3 Pro quality review.
How it works:
- Describe your diagram in natural language
- Nano Banana Pro generates publication-quality images automatically
- Gemini 3 Pro reviews quality against document-type thresholds
- Smart iteration: Only regenerates if quality is below threshold
- Professional output in minutes
- No coding, templates, or manual drawing required
Quality Thresholds by Document Type:
| Document Type | Threshold | Description |
|---|---|---|
| specification | 8.5/10 | Technical specs, PRDs |
| architecture | 8.0/10 | Architecture documents |
| proposal | 8.0/10 | Business proposals |
| sprint | 7.5/10 | Sprint planning docs |
| presentation | 6.5/10 | Slides, talks |
| default | 7.5/10 | General purpose |
本方式使用Nano Banana Pro AI生成图表,并由Gemini 3 Pro进行质量审核。
工作原理:
- 用自然语言描述你的图表需求
- Nano Banana Pro自动生成出版级质量的图片
- Gemini 3 Pro会根据文档类型阈值审核质量
- 智能迭代:仅当质量低于阈值时才会重新生成
- 数分钟内即可生成专业级输出
- 无需编码、模板或手动绘图
按文档类型划分的质量阈值:
| 文档类型 | 阈值 | 说明 |
|---|---|---|
| specification | 8.5/10 | 技术规格、PRD |
| architecture | 8.0/10 | 架构文档 |
| proposal | 8.0/10 | 商业提案 |
| sprint | 7.5/10 | 冲刺规划文档 |
| presentation | 6.5/10 | 幻灯片、演讲材料 |
| default | 7.5/10 | 通用场景 |
When to Use This Skill
本技能的适用场景
This skill should be used when:
- Creating system architecture diagrams (C4 model, microservices, etc.)
- Illustrating data flow and integration patterns
- Drawing sequence diagrams for API interactions
- Visualizing database schemas and data models
- Creating deployment architecture diagrams (AWS, GCP, Azure)
- Depicting component relationships and dependencies
- Generating network topologies and infrastructure layouts
- Illustrating CI/CD pipelines and deployment workflows
本技能适用于以下情况:
- 创建系统架构图(C4模型、微服务等)
- 展示数据流和集成模式
- 绘制API交互的时序图
- 可视化数据库架构和数据模型
- 创建部署架构图(AWS、GCP、Azure)
- 展示组件关系和依赖
- 生成网络拓扑和基础设施布局
- 展示CI/CD流水线和部署工作流
Quick Start: Generate Any Diagram
快速开始:生成任意图表
bash
undefinedbash
undefinedSystem architecture (highest quality: 8.5/10)
系统架构(最高质量:8.5/10)
python .claude/skills/project-diagrams/scripts/generate_schematic.py "Microservices architecture with API gateway, auth service, user service, and PostgreSQL" -o diagrams/architecture.png --doc-type specification
python .claude/skills/project-diagrams/scripts/generate_schematic.py "Microservices architecture with API gateway, auth service, user service, and PostgreSQL" -o diagrams/architecture.png --doc-type specification
C4 Context diagram
C4上下文图
python .claude/skills/project-diagrams/scripts/generate_schematic.py "C4 Context diagram showing e-commerce system with payment gateway, inventory, customers" -o diagrams/c4_context.png --doc-type architecture
python .claude/skills/project-diagrams/scripts/generate_schematic.py "C4 Context diagram showing e-commerce system with payment gateway, inventory, customers" -o diagrams/c4_context.png --doc-type architecture
Sequence diagram
时序图
python .claude/skills/project-diagrams/scripts/generate_schematic.py "Sequence diagram: user authentication flow with client, API, auth service, database" -o diagrams/auth_sequence.png
python .claude/skills/project-diagrams/scripts/generate_schematic.py "Sequence diagram: user authentication flow with client, API, auth service, database" -o diagrams/auth_sequence.png
Data flow diagram
数据流图
python .claude/skills/project-diagrams/scripts/generate_schematic.py "Data flow: user input -> API -> validation -> business logic -> database -> response" -o diagrams/data_flow.png
python .claude/skills/project-diagrams/scripts/generate_schematic.py "Data flow: user input -> API -> validation -> business logic -> database -> response" -o diagrams/data_flow.png
AWS deployment
AWS部署图
python .claude/skills/project-diagrams/scripts/generate_schematic.py "AWS deployment: Route53 -> CloudFront -> ALB -> ECS Fargate -> RDS Aurora" -o diagrams/aws_deployment.png
undefinedpython .claude/skills/project-diagrams/scripts/generate_schematic.py "AWS deployment: Route53 -> CloudFront -> ALB -> ECS Fargate -> RDS Aurora" -o diagrams/aws_deployment.png
undefinedDiagram Types for Project Planning
适用于项目规划的图表类型
1. System Architecture Diagrams
1. 系统架构图
bash
python .claude/skills/project-diagrams/scripts/generate_schematic.py \
"System architecture for SaaS application: \
Frontend (React) -> API Gateway -> Microservices (Auth, Users, Payments). \
Services connect to PostgreSQL and Redis. Event bus (Kafka) for async. \
Use boxes with different colors for each service layer." \
-o diagrams/system_architecture.pngbash
python .claude/skills/project-diagrams/scripts/generate_schematic.py \
"System architecture for SaaS application: \
Frontend (React) -> API Gateway -> Microservices (Auth, Users, Payments). \
Services connect to PostgreSQL and Redis. Event bus (Kafka) for async. \
Use boxes with different colors for each service layer." \
-o diagrams/system_architecture.png2. C4 Model Diagrams
2. C4模型图
bash
undefinedbash
undefinedContext Level
上下文层级
python .claude/skills/project-diagrams/scripts/generate_schematic.py
"C4 Context diagram: Central 'Inventory System' box.
External actors: Warehouse Staff, Suppliers, Customers.
External systems: ERP, Payment Gateway, Shipping.
Bidirectional arrows with relationship labels."
-o diagrams/c4_context.png
"C4 Context diagram: Central 'Inventory System' box.
External actors: Warehouse Staff, Suppliers, Customers.
External systems: ERP, Payment Gateway, Shipping.
Bidirectional arrows with relationship labels."
-o diagrams/c4_context.png
python .claude/skills/project-diagrams/scripts/generate_schematic.py
"C4 Context diagram: Central 'Inventory System' box.
External actors: Warehouse Staff, Suppliers, Customers.
External systems: ERP, Payment Gateway, Shipping.
Bidirectional arrows with relationship labels."
-o diagrams/c4_context.png
"C4 Context diagram: Central 'Inventory System' box.
External actors: Warehouse Staff, Suppliers, Customers.
External systems: ERP, Payment Gateway, Shipping.
Bidirectional arrows with relationship labels."
-o diagrams/c4_context.png
Container Level
容器层级
python .claude/skills/project-diagrams/scripts/generate_schematic.py
"C4 Container diagram: Web App (React) -> API Gateway (Kong) ->
Microservices: Inventory (Node.js), Orders (Python), Notifications (Go).
Databases: PostgreSQL, MongoDB. Message Queue: RabbitMQ."
-o diagrams/c4_container.png
"C4 Container diagram: Web App (React) -> API Gateway (Kong) ->
Microservices: Inventory (Node.js), Orders (Python), Notifications (Go).
Databases: PostgreSQL, MongoDB. Message Queue: RabbitMQ."
-o diagrams/c4_container.png
undefinedpython .claude/skills/project-diagrams/scripts/generate_schematic.py
"C4 Container diagram: Web App (React) -> API Gateway (Kong) ->
Microservices: Inventory (Node.js), Orders (Python), Notifications (Go).
Databases: PostgreSQL, MongoDB. Message Queue: RabbitMQ."
-o diagrams/c4_container.png
"C4 Container diagram: Web App (React) -> API Gateway (Kong) ->
Microservices: Inventory (Node.js), Orders (Python), Notifications (Go).
Databases: PostgreSQL, MongoDB. Message Queue: RabbitMQ."
-o diagrams/c4_container.png
undefined3. Sequence Diagrams
3. 时序图
bash
python .claude/skills/project-diagrams/scripts/generate_schematic.py \
"Sequence diagram for checkout: User, Frontend, API, Cart, Payment, Order, Database. \
Flow: checkout click -> validate cart -> process payment -> create order -> store -> response. \
Include error path for payment failure." \
-o diagrams/checkout_sequence.pngbash
python .claude/skills/project-diagrams/scripts/generate_schematic.py \
"Sequence diagram for checkout: User, Frontend, API, Cart, Payment, Order, Database. \
Flow: checkout click -> validate cart -> process payment -> create order -> store -> response. \
Include error path for payment failure." \
-o diagrams/checkout_sequence.png4. Data Model / ERD
4. 数据模型/ERD
bash
python .claude/skills/project-diagrams/scripts/generate_schematic.py \
"ERD for e-commerce: Users has_many Orders has_many OrderItems belongs_to Products. \
Products belongs_to Categories. Show PKs, FKs, crow's foot notation." \
-o diagrams/data_model.pngbash
python .claude/skills/project-diagrams/scripts/generate_schematic.py \
"ERD for e-commerce: Users has_many Orders has_many OrderItems belongs_to Products. \
Products belongs_to Categories. Show PKs, FKs, crow's foot notation." \
-o diagrams/data_model.png5. Cloud Infrastructure
5. 云基础设施图
bash
python .claude/skills/project-diagrams/scripts/generate_schematic.py \
"AWS architecture: VPC with public/private subnets in 2 AZs. \
Public: ALB, NAT. Private: ECS Fargate, RDS Aurora. \
Route53 -> CloudFront -> ALB. CloudWatch monitoring." \
-o diagrams/aws_infrastructure.pngbash
python .claude/skills/project-diagrams/scripts/generate_schematic.py \
"AWS architecture: VPC with public/private subnets in 2 AZs. \
Public: ALB, NAT. Private: ECS Fargate, RDS Aurora. \
Route53 -> CloudFront -> ALB. CloudWatch monitoring." \
-o diagrams/aws_infrastructure.png6. CI/CD Pipeline
6. CI/CD流水线图
bash
python .claude/skills/project-diagrams/scripts/generate_schematic.py \
"CI/CD pipeline: GitHub push -> Build -> Test -> Security Scan -> \
Deploy Staging -> Integration Tests -> Approval -> Production. \
Tools: GitHub Actions, Docker, Jest, Snyk, ArgoCD, K8s." \
-o diagrams/cicd_pipeline.pngbash
python .claude/skills/project-diagrams/scripts/generate_schematic.py \
"CI/CD pipeline: GitHub push -> Build -> Test -> Security Scan -> \
Deploy Staging -> Integration Tests -> Approval -> Production. \
Tools: GitHub Actions, Docker, Jest, Snyk, ArgoCD, K8s." \
-o diagrams/cicd_pipeline.pngConfiguration
配置
bash
export OPENROUTER_API_KEY='your_api_key_here'bash
export OPENROUTER_API_KEY='your_api_key_here'Get key at: https://openrouter.ai/keys
获取密钥地址:https://openrouter.ai/keys
undefinedundefinedPrompt Tips
提示技巧
1. Architecture Style:
- "Microservices architecture with bounded contexts"
- "Monolithic with layered architecture"
- "Event-driven with CQRS pattern"
2. Technology Stack:
- "React frontend, Node.js API, PostgreSQL, Redis"
- "AWS Lambda with API Gateway and SQS"
- "Kubernetes with Istio service mesh"
3. Relationships:
- "Synchronous REST calls between services"
- "Async communication via Kafka events"
- "Database replication primary to replicas"
1. 架构风格:
- "Microservices architecture with bounded contexts"
- "Monolithic with layered architecture"
- "Event-driven with CQRS pattern"
2. 技术栈:
- "React frontend, Node.js API, PostgreSQL, Redis"
- "AWS Lambda with API Gateway and SQS"
- "Kubernetes with Istio service mesh"
3. 关系描述:
- "Synchronous REST calls between services"
- "Async communication via Kafka events"
- "Database replication primary to replicas"
Integration
集成
Works with other project planning skills:
- architecture-research - Diagrams from ADRs
- building-blocks - Component visualizations
- sprint-planning - Workflow diagrams
可与其他项目规划技能配合使用:
- architecture-research - 从ADR生成图表
- building-blocks - 组件可视化
- sprint-planning - 工作流图表
Quick Reference
快速参考
| Diagram Type | Use Case |
|---|---|
| System Architecture | High-level system overview |
| C4 Context | System boundaries, external interactions |
| C4 Container | Internal services, data stores |
| Sequence | API flows, interactions |
| ERD | Database schema design |
| Deployment | Cloud infrastructure |
| CI/CD Pipeline | Build/deployment workflow |
| Component | Internal service structure |
| 图表类型 | 适用场景 |
|---|---|
| System Architecture | 系统高层概览 |
| C4 Context | 系统边界、外部交互 |
| C4 Container | 内部服务、数据存储 |
| Sequence | API流程、交互 |
| ERD | 数据库架构设计 |
| Deployment | 云基础设施 |
| CI/CD Pipeline | 构建/部署工作流 |
| Component | 内部服务结构 |
Option 2: Mermaid (Recommended for Version Control)
选项2:Mermaid(推荐用于版本控制的场景)
Mermaid generates diagrams from text-based code, perfect for documentation that lives in git repositories.
Mermaid通过基于文本的代码生成图表,非常适合存储在Git仓库中的文档。
Quick Start: Inline Mermaid
快速开始:内嵌Mermaid
Embed directly in markdown files:
markdown
```mermaid
flowchart LR
A[Client] --> B[API Gateway]
B --> C[Auth Service]
B --> D[User Service]
C --> E[(Database)]
D --> E
```直接嵌入到Markdown文件中:
markdown
```mermaid
flowchart LR
A[Client] --> B[API Gateway]
B --> C[Auth Service]
B --> D[User Service]
C --> E[(Database)]
D --> E
```Mermaid Diagram Types for Project Planning
适用于项目规划的Mermaid图表类型
1. System Architecture (Flowchart)
1. 系统架构图(流程图)
mermaid
flowchart TB
subgraph Frontend
A[React App]
B[Mobile App]
end
subgraph API Layer
C[API Gateway]
D[Load Balancer]
end
subgraph Services
E[Auth Service]
F[User Service]
G[Order Service]
end
subgraph Data
H[(PostgreSQL)]
I[(Redis Cache)]
J[(S3 Storage)]
end
A --> D
B --> D
D --> C
C --> E & F & G
E --> H
F --> H & I
G --> H & Jmermaid
flowchart TB
subgraph Frontend
A[React App]
B[Mobile App]
end
subgraph API Layer
C[API Gateway]
D[Load Balancer]
end
subgraph Services
E[Auth Service]
F[User Service]
G[Order Service]
end
subgraph Data
H[(PostgreSQL)]
I[(Redis Cache)]
J[(S3 Storage)]
end
A --> D
B --> D
D --> C
C --> E & F & G
E --> H
F --> H & I
G --> H & J2. Sequence Diagrams
2. 时序图
mermaid
sequenceDiagram
participant U as User
participant F as Frontend
participant A as API Gateway
participant Auth as Auth Service
participant DB as Database
U->>F: Click Login
F->>A: POST /auth/login
A->>Auth: Validate credentials
Auth->>DB: Query user
DB-->>Auth: User data
Auth-->>A: JWT token
A-->>F: 200 OK + token
F-->>U: Redirect to dashboardmermaid
sequenceDiagram
participant U as User
participant F as Frontend
participant A as API Gateway
participant Auth as Auth Service
participant DB as Database
U->>F: Click Login
F->>A: POST /auth/login
A->>Auth: Validate credentials
Auth->>DB: Query user
DB-->>Auth: User data
Auth-->>A: JWT token
A-->>F: 200 OK + token
F-->>U: Redirect to dashboard3. C4 Model Diagrams
3. C4模型图
mermaid
C4Context
title System Context Diagram - Inventory Management
Person(user, "Warehouse Staff", "Manages inventory")
Person(admin, "Admin", "Configures system")
System(inventory, "Inventory System", "Core application")
System_Ext(erp, "ERP System", "Enterprise resource planning")
System_Ext(shipping, "Shipping API", "Delivery tracking")
Rel(user, inventory, "Uses")
Rel(admin, inventory, "Configures")
Rel(inventory, erp, "Syncs data")
Rel(inventory, shipping, "Tracks shipments")mermaid
C4Context
title System Context Diagram - Inventory Management
Person(user, "Warehouse Staff", "Manages inventory")
Person(admin, "Admin", "Configures system")
System(inventory, "Inventory System", "Core application")
System_Ext(erp, "ERP System", "Enterprise resource planning")
System_Ext(shipping, "Shipping API", "Delivery tracking")
Rel(user, inventory, "Uses")
Rel(admin, inventory, "Configures")
Rel(inventory, erp, "Syncs data")
Rel(inventory, shipping, "Tracks shipments")4. Entity Relationship Diagrams
4. 实体关系图
mermaid
erDiagram
USER ||--o{ ORDER : places
USER {
uuid id PK
string email UK
string name
timestamp created_at
}
ORDER ||--|{ ORDER_ITEM : contains
ORDER {
uuid id PK
uuid user_id FK
decimal total
string status
timestamp created_at
}
ORDER_ITEM }o--|| PRODUCT : references
ORDER_ITEM {
uuid id PK
uuid order_id FK
uuid product_id FK
int quantity
decimal price
}
PRODUCT {
uuid id PK
string name
decimal price
int stock
}mermaid
erDiagram
USER ||--o{ ORDER : places
USER {
uuid id PK
string email UK
string name
timestamp created_at
}
ORDER ||--|{ ORDER_ITEM : contains
ORDER {
uuid id PK
uuid user_id FK
decimal total
string status
timestamp created_at
}
ORDER_ITEM }o--|| PRODUCT : references
ORDER_ITEM {
uuid id PK
uuid order_id FK
uuid product_id FK
int quantity
decimal price
}
PRODUCT {
uuid id PK
string name
decimal price
int stock
}5. Sprint Timeline (Gantt Chart)
5. 冲刺时间线(甘特图)
mermaid
gantt
title Sprint 1 - Foundation
dateFormat YYYY-MM-DD
section Infrastructure
CI/CD Setup :done, infra1, 2025-01-06, 3d
Database Setup :active, infra2, after infra1, 2d
section Authentication
User Registration :auth1, after infra2, 3d
Login/Logout :auth2, after auth1, 2d
JWT Implementation :auth3, after auth2, 2d
section Testing
Unit Tests :test1, after auth3, 2d
Integration Tests :test2, after test1, 2dmermaid
gantt
title Sprint 1 - Foundation
dateFormat YYYY-MM-DD
section Infrastructure
CI/CD Setup :done, infra1, 2025-01-06, 3d
Database Setup :active, infra2, after infra1, 2d
section Authentication
User Registration :auth1, after infra2, 3d
Login/Logout :auth2, after auth1, 2d
JWT Implementation :auth3, after auth2, 2d
section Testing
Unit Tests :test1, after auth3, 2d
Integration Tests :test2, after test1, 2d6. State Diagrams (Workflows)
6. 状态图(工作流)
mermaid
stateDiagram-v2
[*] --> Draft
Draft --> Pending: Submit
Pending --> Approved: Approve
Pending --> Rejected: Reject
Rejected --> Draft: Revise
Approved --> Published: Publish
Published --> Archived: Archive
Archived --> [*]mermaid
stateDiagram-v2
[*] --> Draft
Draft --> Pending: Submit
Pending --> Approved: Approve
Pending --> Rejected: Reject
Rejected --> Draft: Revise
Approved --> Published: Publish
Published --> Archived: Archive
Archived --> [*]7. Component Diagrams (Mindmap)
7. 组件图(思维导图)
mermaid
mindmap
root((Inventory System))
Core Services
Auth Service
Inventory Service
Order Service
Notification Service
Data Layer
PostgreSQL
Redis
S3
Infrastructure
AWS ECS
CloudFront
Route53
Integrations
ERP Sync
Shipping APIs
Payment Gatewaymermaid
mindmap
root((Inventory System))
Core Services
Auth Service
Inventory Service
Order Service
Notification Service
Data Layer
PostgreSQL
Redis
S3
Infrastructure
AWS ECS
CloudFront
Route53
Integrations
ERP Sync
Shipping APIs
Payment GatewayGenerating Mermaid to PNG
将Mermaid转换为PNG
For documents requiring image files, use the automatic renderer with fallbacks:
bash
undefined对于需要图片文件的文档,使用带有 fallback 机制的自动渲染器:
bash
undefinedAutomatic rendering with fallback (mmdc → Kroki.io → Nano Banana)
自动渲染(mmdc → Kroki.io → Nano Banana)
python .claude/skills/project-diagrams/scripts/render_mermaid.py diagram.md -o output.png
python .claude/skills/project-diagrams/scripts/render_mermaid.py diagram.md -o output.png
Batch render all Mermaid files in a directory
批量渲染目录下所有Mermaid文件
python .claude/skills/project-diagrams/scripts/render_mermaid.py diagrams/ --batch
python .claude/skills/project-diagrams/scripts/render_mermaid.py diagrams/ --batch
Force a specific method
强制使用特定方法
python .claude/skills/project-diagrams/scripts/render_mermaid.py diagram.md --method kroki
python .claude/skills/project-diagrams/scripts/render_mermaid.py diagram.md --method nano-banana
python .claude/skills/project-diagrams/scripts/render_mermaid.py diagram.md --method kroki
python .claude/skills/project-diagrams/scripts/render_mermaid.py diagram.md --method nano-banana
Check if mmdc is available
检查mmdc是否可用
python .claude/skills/project-diagrams/scripts/render_mermaid.py --check-mmdc
**Multi-Tier Fallback System:**
| Priority | Method | Requirements | Quality |
|----------|--------|--------------|---------|
| 1 | Local mmdc | `npm install -g @mermaid-js/mermaid-cli` | Best (offline) |
| 2 | Kroki.io API | Internet connection | Good (free API) |
| 3 | Nano Banana AI | `OPENROUTER_API_KEY` | Good (AI-generated) |
| 4 | Keep markdown | None | Rendered by viewer |
The renderer automatically tries each method in order until one succeeds.python .claude/skills/project-diagrams/scripts/render_mermaid.py --check-mmdc
**多层Fallback机制:**
| 优先级 | 方法 | 要求 | 质量 |
|----------|--------|--------------|---------|
| 1 | Local mmdc | `npm install -g @mermaid-js/mermaid-cli` | 最佳(离线) |
| 2 | Kroki.io API | 互联网连接 | 良好(免费API) |
| 3 | Nano Banana AI | `OPENROUTER_API_KEY` | 良好(AI生成) |
| 4 | 保留Markdown | 无 | 由查看器渲染 |
渲染器会按顺序自动尝试每种方法,直到成功为止。Manual mmdc Usage
手动使用mmdc
If you prefer direct control:
bash
undefined如果你更喜欢直接控制:
bash
undefinedInstall mermaid-cli
安装mermaid-cli
npm install -g @mermaid-js/mermaid-cli
npm install -g @mermaid-js/mermaid-cli
Generate PNG from .mmd file
从.mmd文件生成PNG
mmdc -i diagram.mmd -o diagrams/output.png -t neutral -b transparent
mmdc -i diagram.mmd -o diagrams/output.png -t neutral -b transparent
Generate SVG (sharper, scalable)
生成SVG(更清晰、可缩放)
mmdc -i diagram.mmd -o diagrams/output.svg -t neutral
mmdc -i diagram.mmd -o diagrams/output.svg -t neutral
With custom width
自定义宽度
mmdc -i diagram.mmd -o diagrams/output.png -w 1200
undefinedmmdc -i diagram.mmd -o diagrams/output.png -w 1200
undefinedMermaid Themes
Mermaid主题
bash
undefinedbash
undefinedAvailable themes: default, neutral, dark, forest
可用主题:default, neutral, dark, forest
mmdc -i diagram.mmd -o output.png -t forest
| Theme | Best For |
|-------|----------|
| `default` | General purpose, blue tones |
| `neutral` | Professional documents, grayscale-friendly |
| `dark` | Dark mode UIs, presentations |
| `forest` | Environmental/green themed projects |mmdc -i diagram.mmd -o output.png -t forest
| 主题 | 适用场景 |
|-------|----------|
| `default` | 通用场景、蓝色调 |
| `neutral` | 专业文档、适合灰度打印 |
| `dark` | 深色模式UI、演示文稿 |
| `forest` | 环保/绿色主题项目 |Mermaid in Project Planning Documents
项目规划文档中的Mermaid使用
Recommended usage in markdown documentation:
markdown
undefinedMarkdown文档中的推荐用法:
markdown
undefinedSystem Architecture
系统架构
The system follows a microservices architecture:
mermaid
flowchart LR
Client --> Gateway --> Services --> Database系统采用微服务架构:
mermaid
flowchart LR
Client --> Gateway --> Services --> DatabaseAPI Sequence
API交互流程
mermaid
sequenceDiagram
Client->>API: Request
API->>Service: Process
Service-->>API: Response
API-->>Client: Resultundefinedmermaid
sequenceDiagram
Client->>API: Request
API->>Service: Process
Service-->>API: Response
API-->>Client: ResultundefinedWhen to Use Which
场景选择建议
| Scenario | Recommendation |
|---|---|
| Final deliverable PDFs | Nano Banana Pro AI |
| GitHub/GitLab docs | Mermaid (inline) |
| Architecture Decision Records | Mermaid |
| Client presentations | Nano Banana Pro AI |
| Sprint planning docs | Mermaid (Gantt charts) |
| Quick whiteboard-style | Mermaid |
| Complex custom visuals | Nano Banana Pro AI |
| Collaborative editing | Mermaid |
| 场景 | 推荐方案 |
|---|---|
| 最终交付PDF | Nano Banana Pro AI |
| GitHub/GitLab文档 | Mermaid(内嵌) |
| 架构决策记录 | Mermaid |
| 客户演示文稿 | Nano Banana Pro AI |
| 冲刺规划文档 | Mermaid(甘特图) |
| 快速白板风格图表 | Mermaid |
| 复杂自定义视觉效果 | Nano Banana Pro AI |
| 协作编辑 | Mermaid |
Mermaid Resources
Mermaid资源
- Live Editor: https://mermaid.live
- Documentation: https://mermaid.js.org/
- GitHub Rendering: Native support in markdown files
- VS Code Extension: "Mermaid Markdown Syntax Highlighting"
- 在线编辑器: https://mermaid.live
- 文档: https://mermaid.js.org/
- GitHub渲染: Markdown文件原生支持
- VS Code扩展: "Mermaid Markdown Syntax Highlighting"