Architecture Design
Generate professional software architecture documentation with visual diagrams and API specifications through structured interviews. Create complete ARCHITECTURE.md files covering all required sections with technology-specific patterns, C4 model diagrams, and OpenAPI 3.0 specifications.
Core Workflow
Step 1: Assess Project Type
Determine the project type by asking the user:
- •New project? Gather requirements and design architecture
- •Existing system? Document current state
- •Update needed? Identify changed components
Step 2: Gather Essential Information
Conduct a brief interview (5-7 questions maximum) to collect:
- •Architecture pattern: Monolith, microservices, or serverless?
- •Primary technology: Node.js, Python, Java, or other?
- •Key components: Main services or modules?
- •Data stores: Databases and caches?
- •Cloud provider: AWS, GCP, Azure, or on-premise?
- •Deployment: How is it deployed?
- •External integrations: Third-party services?
Step 3: Select Template and Load References
Choose template based on architecture pattern:
- •Monolith → Use
assets/ARCHITECTURE-monolith.md - •Microservices → Use
assets/ARCHITECTURE-microservices.md - •Uncertain → Use
assets/ARCHITECTURE.md
Load technology-specific references:
- •Node.js projects → Load
references/nodejs.mdfor Express, NestJS, Fastify patterns - •Python projects → Load
references/python.mdfor Django, Flask, FastAPI patterns - •Java projects → Load
references/java.mdfor Spring Boot, Jakarta EE patterns
Load pattern-specific references when applicable:
- •Microservices → Load
references/microservices.mdfor service boundaries and communication patterns - •Serverless → Load
references/serverless.mdfor function organization and event sources
Step 4: Generate System Diagram
Generate appropriate diagrams using scripts/generate_diagram.py:
For monolithic architectures:
python scripts/generate_diagram.py layered
For microservices architectures:
python scripts/generate_diagram.py flow
For simple systems:
python scripts/generate_diagram.py simple
Customize diagrams with JSON configuration for specific components.
Step 5: Populate Template
Complete the template sections in the specified order:
- •Project Identification (Section 10) - Add project name, repository, contact, date
- •Project Structure (Section 1) - Define directory layout
- •System Diagram (Section 2) - Insert generated diagram
- •Core Components (Section 3) - Document components from interview
- •Data Stores (Section 4) - Describe databases and caches
- •External Integrations (Section 5) - List third-party services
- •Deployment (Section 6) - Detail infrastructure setup
- •Security (Section 7) - Specify authentication and encryption
- •Development (Section 8) - Outline setup and testing procedures
- •Future Considerations (Section 9) - Document roadmap items
- •Glossary (Section 11) - Define domain terminology
Apply technology-specific patterns from loaded references to enhance each section.
Step 6: Validate
Execute the validation script to ensure quality:
python scripts/validate_architecture.py ARCHITECTURE.md
Address any issues or warnings before delivering the documentation.
Interview Best Practices
Maintain focused questioning:
- •Ask 2-3 questions at a time
- •Build upon previous answers
- •Skip redundant questions
Adapt communication style:
- •Technical users: Use precise terminology
- •Non-technical users: Simplify language
- •Uncertain users: Offer defaults or placeholders
Handle information gaps:
- •Mark uncertain items for review
- •Add [TODO] for missing information
- •Suggest reasonable defaults based on context
Technology-Specific Guidance
Reference Loading Guidelines
Load references/nodejs.md for:
- •Express, NestJS, Fastify projects
- •Node.js microservices
- •Serverless Node functions
Load references/python.md for:
- •Django, Flask, FastAPI projects
- •Python microservices
- •Data pipelines and ML systems
Load references/java.md for:
- •Spring Boot applications
- •Jakarta EE systems
- •Java microservices
Load references/workflows.md for:
- •Complex interview scenarios
- •Detailed process guidance
- •Documentation update workflows
Applying Technology Patterns
After loading references, apply the patterns to enhance:
- •Project structure recommendations
- •Deployment configurations
- •Framework-specific best practices
- •Common library suggestions
- •Testing strategies and approaches
Pattern-Specific Guidance
Microservices Architecture
Load references/microservices.md and include these elements:
- •Service boundaries and responsibilities
- •Communication patterns (synchronous vs asynchronous)
- •API gateway configuration
- •Service discovery mechanism
- •Data management approach
- •Observability and monitoring setup
Use the microservices template (assets/ARCHITECTURE-microservices.md) for proper structure.
Serverless Architecture
Load references/serverless.md and include these elements:
- •Function organization and boundaries
- •Event sources and triggers
- •State management approach
- •Cold start mitigation techniques
- •Cost optimization strategies
Monolithic Architecture
Use the monolith template (assets/ARCHITECTURE-monolith.md) and emphasize:
- •Layered architecture patterns
- •Module organization principles
- •Potential future refactoring paths
- •Scaling strategy and approaches
Diagram Generation Examples
Simple Architecture Diagram
python scripts/generate_diagram.py simple '{"components": ["User", "API", "DB"], "connections": [["User", "API"], ["API", "DB"]]}'
Layered Architecture Diagram
python scripts/generate_diagram.py layered '{"Presentation": ["Web UI"], "Business": ["API"], "Data": ["PostgreSQL"]}'
Flow Architecture Diagram
python scripts/generate_diagram.py flow '[{"from": "Client", "to": "Gateway", "label": "HTTP"}, {"from": "Gateway", "to": "Service", "label": "route"}]'
C4 Context Diagram
python scripts/generate_diagram.py c4 '{"system": "E-commerce Platform", "actors": ["Customer", "Admin"], "external_systems": ["Payment Gateway", "Email Service"]}'
Integrate generated diagrams into Section 2 (System Diagram) of the ARCHITECTURE.md template.
Validation
Execute validation before delivering documentation:
python scripts/validate_architecture.py ARCHITECTURE.md
Validation checks performed:
- •Verify all 11 sections are present
- •Confirm required fields in Project Identification section
- •Ensure minimal content in each section
- •Count and report placeholder usage
Address any warnings about missing content or excessive placeholders.
Documentation Update Workflow
For incremental updates:
- •Identify what has changed
- •Update only affected sections
- •Update the date in Section 10 (Project Identification)
- •Re-run validation to ensure quality
For major updates:
- •Review the entire document
- •Regenerate diagrams if structure has changed
- •Update multiple sections as needed
- •Consider adding version notes
Mermaid Diagram Generation
After creating ARCHITECTURE.md, generate the complete set of 5 Mermaid diagrams.
Load Mermaid Instructions
When users request diagrams or complete documentation packages:
Load references/mermaid-diagrams.md
Generate Complete Diagram Set
Create all 5 diagrams following the guidance in mermaid-diagrams.md:
- •C4 Context (Level 1) - System in its broader context
- •C4 Container (Level 2) - Main application containers
- •C4 Component (Level 3) - Internal component structure
- •Data Flow - How data moves through the system
- •C4 Deployment - Infrastructure topology and deployment
Use scripts/generate_mermaid.py with system JSON configuration.
Save diagrams as separate .mmd files:
- •
01-context.mmd - •
02-container.mmd - •
03-component.mmd - •
04-dataflow.mmd - •
05-deployment.mmd
Embed diagrams in ARCHITECTURE.md Section 2 as code blocks for easy viewing and editing.
OpenAPI Specification Generation
For systems with REST APIs, generate comprehensive OpenAPI 3.0 specifications.
Generate API Specifications
Use scripts/generate_openapi.py with appropriate parameters:
For simple CRUD operations:
python scripts/generate_openapi.py "ResourceName"
For custom API specifications:
python scripts/generate_openapi.py '{"system_name": "...", "endpoints": [...]}'
Save the generated specification as openapi.json in the project directory.
Complete Documentation Workflow
Follow this end-to-end workflow for comprehensive architecture documentation:
- •Conduct structured interview (5-7 questions maximum)
- •Select appropriate template and load relevant references
- •Setup work directory: Use current working directory
$(pwd) - •Generate ARCHITECTURE.md with all 11 sections completed
- •Generate Mermaid diagrams (5 separate .mmd files) in work directory root
- •Generate OpenAPI specification (if applicable) in work directory
- •Deliver all generated artifacts to the user
Deliverable Organization
Organize generated documentation files as follows:
├── ARCHITECTURE.md # Main architecture document
├── openapi.json # API specification (if applicable)
├── *.mmd (5 files) # Mermaid diagram sources
│ ├── 01-context.mmd
│ ├── 02-container.mmd
│ ├── 03-component.mmd
│ ├── 04-dataflow.mmd
│ └── 05-deployment.mmd
└── diagrams/ (created during packaging)
└── *.png (5 files, if rendered to images)
Example Usage
User request: "Create architecture documentation for my Node.js microservices project"
Execution approach:
- •Select microservices template (
assets/ARCHITECTURE-microservices.md) - •Load
references/nodejs.mdandreferences/microservices.md - •Conduct focused interview: services, databases, communication patterns, deployment
- •Generate flow diagram using
scripts/generate_diagram.py flow - •Populate all sections with Node.js and microservices-specific patterns
- •Validate using
scripts/validate_architecture.py - •Create comprehensive ARCHITECTURE.md in work directory
Common Usage Scenarios
New Greenfield Projects
- •Use base template (
assets/ARCHITECTURE.md) - •Focus on design decisions and architecture rationale
- •Include justification for technology choices
- •Emphasize planned architecture and future scalability
Existing System Documentation
- •Ask about current pain points and challenges
- •Document the as-is state accurately
- •Note planned improvements in Section 9 (Future Considerations)
- •Capture current technology stack and limitations
Legacy System Analysis
- •Identify undocumented or poorly understood areas
- •Mark uncertain items for further investigation
- •Suggest areas requiring clarification from stakeholders
- •Document assumptions and risks
Architecture Reviews and Updates
- •Update only sections that have changed
- •Preserve information that remains accurate
- •Add new components and relationships
- •Update date in Section 10 and note changes
Best Practices
Efficient documentation creation:
- •Begin with known information and build incrementally
- •Use placeholders for unknown items to maintain momentum
- •Leverage technology references to save time and ensure accuracy
- •Validate frequently to catch issues early
High-quality output standards:
- •Provide specific, concrete details rather than generic descriptions
- •Include actual technology stack versions and configurations
- •Use real service names, purposes, and data flows
- •Document concrete deployment infrastructure and environments
Positive user experience:
- •Avoid overwhelming users with excessive questions
- •Explain the documentation process and next steps
- •Show progress through the 11 sections clearly
- •Offer refinement and improvement after initial delivery