diagram-generator
Generates architecture, database, and system diagrams using Mermaid syntax. Creates visual representations of system architecture, database schemas, component relationships, and data flows.
When & Why to Use This Skill
The Diagram Generator skill automates the creation of professional system architectures, database schemas, and process flows using Mermaid syntax. It solves the challenge of manual documentation by instantly transforming complex technical requirements or code structures into clear, maintainable visual representations, ensuring that system design remains synchronized with development.
Use Cases
- Architecting Microservices: Visualizing component relationships and communication paths between different services.
- Database Schema Design: Generating Entity-Relationship Diagrams (ERD) to document table structures, primary keys, and foreign key relationships.
- Process Flow Mapping: Creating sequence diagrams to illustrate complex API request-response cycles and authentication flows.
- System Onboarding: Generating high-level system overviews to help new developers quickly understand the codebase structure.
- Technical Documentation: Embedding live-updating Mermaid charts into Markdown files to enhance the clarity of READMEs and design docs.
| name | diagram-generator |
|---|---|
| description | Generates architecture, database, and system diagrams using Mermaid syntax. Creates visual representations of system architecture, database schemas, component relationships, and data flows. |
| model | sonnet |
| allowed-tools | read, write, glob, search, codebase_search |
| version | 1.0 |
| error_handling | graceful |
| streaming | supported |
| templates | [architecture-diagram, database-diagram, component-diagram, sequence-diagram] |
Step 1: Identify Diagram Type
Determine what type of diagram is needed:
- Architecture Diagram: System structure and components
- Database Diagram: Schema and relationships
- Component Diagram: Component interactions
- Sequence Diagram: Process flows
- Flowchart: Decision flows
Step 2: Extract Structure
Analyze code and documentation:
- Read architecture documents
- Analyze component structure
- Extract database schema
- Identify relationships
- Understand data flows
Step 3: Generate Mermaid Diagram
Create diagram using Mermaid syntax:
- Use appropriate diagram type
- Define nodes and relationships
- Add labels and descriptions
- Include styling if needed
Step 4: Embed in Documentation
Embed diagram in markdown:
- Use mermaid code blocks
- Add diagram description
- Reference in documentation
Integration with Database Architect Agent:
- Generates database schema diagrams
- Documents table relationships
- Visualizes data models
Integration with Technical Writer Agent:
- Embeds diagrams in documentation
- Creates visual documentation
- Enhances documentation clarity
- Use Mermaid: Standard syntax for compatibility
- Keep Clear: Simple, readable diagrams
- Show Relationships: Include all important connections
- Add Labels: Clear node and edge labels
- Update Regularly: Keep diagrams current with code
graph TB
Client[Client Application]
API[API Gateway]
Auth[Auth Service]
User[User Service]
DB[(Database)]
Client --> API
API --> Auth
API --> User
User --> DB
Auth --> DB
**Database Schema Diagram**
erDiagram
USERS ||--o{ ORDERS : places
USERS {
uuid id PK
string email
string name
}
ORDERS ||--|{ ORDER_ITEMS : contains
ORDERS {
uuid id PK
uuid user_id FK
date created_at
}
ORDER_ITEMS {
uuid id PK
uuid order_id FK
uuid product_id FK
int quantity
}
**Component Diagram**
graph LR
A[Component A] --> B[Component B]
A --> C[Component C]
B --> D[Component D]
C --> D
**Sequence Diagram**
sequenceDiagram
participant User
participant API
participant Auth
participant DB
User->>API: Login Request
API->>Auth: Validate Credentials
Auth->>DB: Query User
DB-->>Auth: User Data
Auth-->>API: JWT Token
API-->>User: Auth Response
**Example Commands**:
# Generate architecture diagram
Generate architecture diagram for the authentication system
# Generate database schema diagram
Generate database schema diagram for the user management module
# Generate component diagram
Generate component diagram showing API service relationships
# Generate sequence diagram
Generate sequence diagram for user login flow