Codebase Architecture Analysis
When to use this skill
Use this skill when you need to understand the high-level architecture and structure of a codebase. Specifically, use it when you need to:
- Create architecture diagrams for documentation
- Understand component relationships and dependencies
- Assess hosting infrastructure and deployment architecture
- Generate comprehensive architectural overviews
- Document data flow between system components
- Create visual representations of code organization
Overview
This skill guides a specialized agent through a comprehensive analysis of a GitHub repository to produce detailed architecture documentation. The analysis includes ASCII diagrams, component maps, infrastructure details, and file-level assessments.
Workflow
Step 1: Repository Setup
Input required:
- GitHub repository URL or
owner/repo format
- Optional: Specific branch or commit to analyze
Actions:
- Clone the repository using the GitHub PAT from environment variables
- Verify the repository is cloned successfully
- Document the repository metadata (language, size, structure)
YOU MUST CLONE THE REPOSITORY AND INSPECT THE FILES USING BASH TOOLS AND GIT CLI RATHER THAN MCP.
Step 2: Codebase Discovery and Assessment
Analyze the directory structure:
- Map the complete directory tree
- Identify major components/modules/packages
- Classify directories by purpose (src, config, tests, build, etc.)
- Count files by type (TypeScript, Python, JSON, etc.)
- Identify entry points and main application files
For each file, assess:
- File type and purpose
- Size and complexity
- Key imports and dependencies
- What module/component it belongs to
- Role in the overall system
Step 3: Create Architecture Diagrams
Create multiple ASCII diagrams:
System Architecture Diagram
- High-level components and their relationships
- External systems and services
- Data flow between components
Deployment Architecture
- Hosting infrastructure (cloud platform, containers, etc.)
- Service relationships
- Network and database layers
File Structure Diagram
- Directory hierarchy showing major components
- Key files and their purposes
- Organization by feature or layer
Data Flow Diagram
- How data moves through the system
- API endpoints and their interactions
- Database access patterns
Example ASCII diagram structure:
┌─────────────────────────────────────────────────┐
│ Client (React) │
├─────────────────────────────────────────────────┤
│ - Components │
│ - Pages │
│ - State Management │
└────────────────┬────────────────────────────────┘
│ HTTP/WebSocket
┌────────────────▼────────────────────────────────┐
│ Backend Server (Node.js) │
├─────────────────────────────────────────────────┤
│ - API Routes │
│ - Authentication │
│ - Business Logic │
└────────────────┬────────────────────────────────┘
│
┌────────────────▼────────────────────────────────┐
│ Database & External APIs │
├─────────────────────────────────────────────────┤
│ - PostgreSQL / MongoDB │
│ - Third-party Services │
└─────────────────────────────────────────────────┘
Step 4: Component Analysis
For each major component, document:
- Purpose and responsibilities
- Key files and entry points
- External dependencies
- Interactions with other components
- API surface (if applicable)
Document component categories:
- Frontend Components: UI components, pages, layouts
- Backend Services: API endpoints, middleware, handlers
- Business Logic: Core algorithms, processing
- Infrastructure: Configuration, build, deployment
- Testing: Test utilities, test files
- Documentation: READMEs, specs, guides
Step 5: Technology Stack Assessment
Identify and document:
- Programming languages used
- Key frameworks and libraries
- Database systems
- External services and APIs
- Development tools and build systems
- Container/deployment technologies
- Version numbers where significant
Step 6: Hosting and Infrastructure Analysis
Assess the deployment architecture:
- Identify hosting platform (AWS, GCP, Vercel, Cloudflare, etc.)
- Document service configuration
- Environment variables
- Build processes
- Deployment scripts
- Identify infrastructure-as-code files (Terraform, Docker, etc.)
- Document scaling considerations
- Identify external service dependencies
Step 7: Generate Final Documentation
Create a comprehensive architecture document including:
Executive Summary
- Project purpose
- High-level architecture overview
- Technology stack
- Hosting platform and deployment
Architecture Diagrams (multiple views as described in Step 3)
Component Catalog
- List of major components
- Purpose of each
- Key files
- Dependencies
File Structure Overview
- Directory layout with purposes
- Important files highlighted
Data Flow Explanation
- How requests are processed
- Database interactions
- External API calls
Technology Details
- Language versions
- Framework versions
- Key library versions
- Database schema summary (if visible in code)
Deployment and Hosting
- Hosting platform details
- Build and deployment process
- Environment configuration
- Scaling considerations
Dependencies and Integrations
- List of external services
- API integrations
- Authentication/authorization approach
Common Patterns
For Monolithic Applications
- Single codebase containing frontend, backend, and shared logic
- Clear separation between presentation, business logic, and data layers
- Review package.json/requirements.txt for all dependencies
For Microservices
- Multiple services in separate directories or repositories
- Service communication documented in deployment config
- API contracts between services
- Separate databases per service (typically)
For Full-Stack Web Applications
- Frontend framework (React, Vue, Angular, etc.)
- Backend framework (Node.js/Express, Python/Django, etc.)
- Database (SQL or NoSQL)
- API layer connecting frontend and backend
Edge Cases
Large Codebases:
- Focus on major components first
- Group related files together
- Create summary before diving into details
Polyglot Repositories:
- Separate analysis by language when relevant
- Document language integration points
- Highlight cross-language dependencies
Complex Infrastructure:
- Document infrastructure-as-code separately
- Identify deployment stages (dev, staging, prod)
- Note auto-scaling or load balancing configurations
Output Format
The final architecture analysis should be delivered as:
- A comprehensive Markdown document with embedded ASCII diagrams
- Clear section headers and navigation
- Links between related sections
- Visual hierarchy showing component relationships
- Concise but complete descriptions
Tools and Resources
The agent may use:
- Git commands to explore repository structure
- File reading tools to examine source code
- Text parsing to extract key information
- ASCII art libraries for diagram generation
Example Use Case
User Request: "Analyze the architecture of the user-management microservice in our platform"
Agent Process:
- Clones the user-management repository
- Maps the directory structure (controllers, models, tests, config)
- Creates ASCII diagrams showing:
- Service components (auth handler, user DB access, role manager)
- Data flow (API request → controller → service → database)
- Deployment (Docker container → Kubernetes → PostgreSQL)
- Documents all dependencies and integrations
- Provides complete architecture documentation
Success Criteria
The analysis is complete when:
- ✅ Repository successfully cloned and analyzed
- ✅ All major components identified
- ✅ Multiple ASCII diagrams created showing different views
- ✅ File structure documented and explained
- ✅ Technology stack clearly identified
- ✅ Hosting/deployment architecture understood
- ✅ Data flow between components visible
- ✅ Comprehensive documentation generated
1---2name: codebase-architecture-analysis3description: Analyze a GitHub codebase to create comprehensive architecture documentation including ASCII diagrams, component relationships, data flow, hosting infrastructure, and file structure assessment.4license: MIT5---67# Codebase Architecture Analysis89## When to use this skill1011Use this skill when you need to understand the high-level architecture and structure of a codebase. Specifically, use it when you need to:12- Create architecture diagrams for documentation13- Understand component relationships and dependencies14- Assess hosting infrastructure and deployment architecture15- Generate comprehensive architectural overviews16- Document data flow between system components17- Create visual representations of code organization1819## Overview2021This skill guides a specialized agent through a comprehensive analysis of a GitHub repository to produce detailed architecture documentation. The analysis includes ASCII diagrams, component maps, infrastructure details, and file-level assessments.2223## Workflow2425### Step 1: Repository Setup2627**Input required:**28- GitHub repository URL or `owner/repo` format29- Optional: Specific branch or commit to analyze3031**Actions:**321. Clone the repository using the GitHub PAT from environment variables332. Verify the repository is cloned successfully343. Document the repository metadata (language, size, structure)3536YOU MUST CLONE THE REPOSITORY AND INSPECT THE FILES USING BASH TOOLS AND GIT CLI RATHER THAN MCP.3738### Step 2: Codebase Discovery and Assessment3940**Analyze the directory structure:**411. Map the complete directory tree422. Identify major components/modules/packages433. Classify directories by purpose (src, config, tests, build, etc.)444. Count files by type (TypeScript, Python, JSON, etc.)455. Identify entry points and main application files4647**For each file, assess:**48- File type and purpose49- Size and complexity50- Key imports and dependencies51- What module/component it belongs to52- Role in the overall system5354### Step 3: Create Architecture Diagrams5556**Create multiple ASCII diagrams:**57581. **System Architecture Diagram**59 - High-level components and their relationships60 - External systems and services61 - Data flow between components62632. **Deployment Architecture**64 - Hosting infrastructure (cloud platform, containers, etc.)65 - Service relationships66 - Network and database layers67683. **File Structure Diagram**69 - Directory hierarchy showing major components70 - Key files and their purposes71 - Organization by feature or layer72734. **Data Flow Diagram**74 - How data moves through the system75 - API endpoints and their interactions76 - Database access patterns7778Example ASCII diagram structure:7980```81┌─────────────────────────────────────────────────┐82│ Client (React) │83├─────────────────────────────────────────────────┤84│ - Components │85│ - Pages │86│ - State Management │87└────────────────┬────────────────────────────────┘88 │ HTTP/WebSocket89┌────────────────▼────────────────────────────────┐90│ Backend Server (Node.js) │91├─────────────────────────────────────────────────┤92│ - API Routes │93│ - Authentication │94│ - Business Logic │95└────────────────┬────────────────────────────────┘96 │97┌────────────────▼────────────────────────────────┐98│ Database & External APIs │99├─────────────────────────────────────────────────┤100│ - PostgreSQL / MongoDB │101│ - Third-party Services │102└─────────────────────────────────────────────────┘103```104105### Step 4: Component Analysis106107**For each major component, document:**108- Purpose and responsibilities109- Key files and entry points110- External dependencies111- Interactions with other components112- API surface (if applicable)113114**Document component categories:**115- **Frontend Components**: UI components, pages, layouts116- **Backend Services**: API endpoints, middleware, handlers117- **Business Logic**: Core algorithms, processing118- **Infrastructure**: Configuration, build, deployment119- **Testing**: Test utilities, test files120- **Documentation**: READMEs, specs, guides121122### Step 5: Technology Stack Assessment123124**Identify and document:**125- Programming languages used126- Key frameworks and libraries127- Database systems128- External services and APIs129- Development tools and build systems130- Container/deployment technologies131- Version numbers where significant132133### Step 6: Hosting and Infrastructure Analysis134135**Assess the deployment architecture:**1361. Identify hosting platform (AWS, GCP, Vercel, Cloudflare, etc.)1372. Document service configuration138 - Environment variables139 - Build processes140 - Deployment scripts1413. Identify infrastructure-as-code files (Terraform, Docker, etc.)1424. Document scaling considerations1435. Identify external service dependencies144145### Step 7: Generate Final Documentation146147**Create a comprehensive architecture document including:**1481491. **Executive Summary**150 - Project purpose151 - High-level architecture overview152 - Technology stack153 - Hosting platform and deployment1541552. **Architecture Diagrams** (multiple views as described in Step 3)1561573. **Component Catalog**158 - List of major components159 - Purpose of each160 - Key files161 - Dependencies1621634. **File Structure Overview**164 - Directory layout with purposes165 - Important files highlighted1661675. **Data Flow Explanation**168 - How requests are processed169 - Database interactions170 - External API calls1711726. **Technology Details**173 - Language versions174 - Framework versions175 - Key library versions176 - Database schema summary (if visible in code)1771787. **Deployment and Hosting**179 - Hosting platform details180 - Build and deployment process181 - Environment configuration182 - Scaling considerations1831848. **Dependencies and Integrations**185 - List of external services186 - API integrations187 - Authentication/authorization approach188189## Common Patterns190191### For Monolithic Applications192- Single codebase containing frontend, backend, and shared logic193- Clear separation between presentation, business logic, and data layers194- Review package.json/requirements.txt for all dependencies195196### For Microservices197- Multiple services in separate directories or repositories198- Service communication documented in deployment config199- API contracts between services200- Separate databases per service (typically)201202### For Full-Stack Web Applications203- Frontend framework (React, Vue, Angular, etc.)204- Backend framework (Node.js/Express, Python/Django, etc.)205- Database (SQL or NoSQL)206- API layer connecting frontend and backend207208## Edge Cases209210**Large Codebases:**211- Focus on major components first212- Group related files together213- Create summary before diving into details214215**Polyglot Repositories:**216- Separate analysis by language when relevant217- Document language integration points218- Highlight cross-language dependencies219220**Complex Infrastructure:**221- Document infrastructure-as-code separately222- Identify deployment stages (dev, staging, prod)223- Note auto-scaling or load balancing configurations224225## Output Format226227The final architecture analysis should be delivered as:2281. A comprehensive Markdown document with embedded ASCII diagrams2292. Clear section headers and navigation2303. Links between related sections2314. Visual hierarchy showing component relationships2325. Concise but complete descriptions233234## Tools and Resources235236The agent may use:237- Git commands to explore repository structure238- File reading tools to examine source code239- Text parsing to extract key information240- ASCII art libraries for diagram generation241242## Example Use Case243244**User Request:** "Analyze the architecture of the user-management microservice in our platform"245246**Agent Process:**2471. Clones the user-management repository2482. Maps the directory structure (controllers, models, tests, config)2493. Creates ASCII diagrams showing:250 - Service components (auth handler, user DB access, role manager)251 - Data flow (API request → controller → service → database)252 - Deployment (Docker container → Kubernetes → PostgreSQL)2534. Documents all dependencies and integrations2545. Provides complete architecture documentation255256## Success Criteria257258The analysis is complete when:259- ✅ Repository successfully cloned and analyzed260- ✅ All major components identified261- ✅ Multiple ASCII diagrams created showing different views262- ✅ File structure documented and explained263- ✅ Technology stack clearly identified264- ✅ Hosting/deployment architecture understood265- ✅ Data flow between components visible266- ✅ Comprehensive documentation generated