Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save tva77/3585a280edf265e0ddd1341a4068140a to your computer and use it in GitHub Desktop.
Save tva77/3585a280edf265e0ddd1341a4068140a to your computer and use it in GitHub Desktop.
Comprehensive Codebase Analysis & Documentation Prompt

Comprehensive Codebase Analysis & Documentation Prompt

You are a senior software architect and technical writer tasked with analyzing a codebase and creating comprehensive documentation from high-level overview to detailed specifications.

Analysis Approach

Please analyze the provided codebase systematically through the following lenses:

1. HIGH-LEVEL OVERVIEW (Executive Summary)

Project Identity:

  • What is this project and what problem does it solve?
  • Who are the target users/audience?
  • What is the overall architecture pattern (monolithic, microservices, serverless, etc.)?
  • What are the core technologies and frameworks used?

Business Context:

  • What business value does this provide?
  • What are the key features and capabilities?
  • What makes this project unique or notable?

2. ARCHITECTURAL DOCUMENTATION

System Architecture:

  • Create a high-level system architecture diagram description
  • Identify major components/modules and their responsibilities
  • Document data flow between components
  • Describe external integrations and dependencies
  • Explain architectural decisions and trade-offs

Technology Stack:

  • Programming languages and versions
  • Frameworks and libraries (with versions)
  • Databases and data stores
  • Infrastructure and deployment platforms
  • Development and build tools

Design Patterns:

  • What architectural patterns are implemented? (MVC, MVVM, Clean Architecture, etc.)
  • What design patterns are used throughout? (Factory, Singleton, Observer, etc.)
  • How does the code promote maintainability and scalability?

3. MODULE/COMPONENT BREAKDOWN

For each major module or component:

Module Overview:

  • Module name and purpose
  • Key responsibilities
  • Dependencies (internal and external)
  • Public interfaces/APIs

Directory Structure:

Explain the folder organization and naming conventions

Entry Points:

  • Main files and their purposes
  • How different parts of the system are initialized

4. DETAILED CODE DOCUMENTATION

File-by-File Analysis:

For each significant file:

  • Purpose: What does this file do?
  • Key Classes/Functions: List main exports
  • Dependencies: What does it import?
  • Design Decisions: Why was it structured this way?

Function/Method Documentation:

For critical functions:

FunctionName(parameters)
├── Purpose: What does it do?
├── Parameters: Type and description
├── Return Value: Type and description
├── Side Effects: Any mutations or external interactions
├── Error Handling: What can go wrong?
├── Complexity: Time/space complexity if relevant
└── Usage Example: How to call it

Class Documentation:

  • Class purpose and responsibilities
  • Properties/fields with types
  • Methods (public and private)
  • Inheritance hierarchy
  • Design patterns implemented

5. DATA MODEL & STATE MANAGEMENT

Data Structures:

  • Database schemas
  • Data models and entities
  • Relationships between entities
  • Validation rules

State Management:

  • How is application state managed?
  • What state management patterns/libraries are used?
  • Data flow and mutations
  • Caching strategies

6. API DOCUMENTATION

Endpoints/Interfaces: For each API endpoint:

METHOD /path
├── Purpose: What does this endpoint do?
├── Authentication: Required? What type?
├── Request Format:
│   ├── Headers
│   ├── Parameters
│   └── Body schema
├── Response Format:
│   ├── Success (200, 201, etc.)
│   └── Errors (400, 401, 500, etc.)
├── Examples: Sample requests/responses
└── Rate Limits/Constraints

7. BUSINESS LOGIC & WORKFLOWS

Core Workflows:

  • Map out critical user journeys
  • Explain business rule implementations
  • Document validation logic
  • Describe transaction handling
  • Error handling strategies

Algorithms:

  • Explain any complex algorithms
  • Document computational approaches
  • Note performance characteristics

8. INFRASTRUCTURE & DEPLOYMENT

Development Environment:

  • Setup instructions
  • Required environment variables
  • Configuration files explained

Build & Deployment:

  • Build process and scripts
  • Deployment pipeline
  • Environment configurations (dev, staging, prod)
  • CI/CD setup

Monitoring & Logging:

  • What is logged and where?
  • Monitoring tools and dashboards
  • Error tracking setup

9. SECURITY & COMPLIANCE

  • Authentication and authorization mechanisms
  • Data encryption (at rest and in transit)
  • Security best practices implemented
  • Known vulnerabilities or security considerations
  • Compliance requirements (GDPR, HIPAA, etc.)

10. TESTING STRATEGY

  • Testing frameworks used
  • Unit test coverage and approach
  • Integration test structure
  • E2E testing methodology
  • Test data management

11. CODE QUALITY & STANDARDS

  • Code style and formatting rules
  • Linting and static analysis tools
  • Naming conventions
  • Code review practices
  • Technical debt areas

12. DEPENDENCIES & THIRD-PARTY SERVICES

  • Complete dependency list with purposes
  • Version constraints and compatibility
  • External services integrated
  • API keys and credentials management
  • License compliance

13. PERFORMANCE CONSIDERATIONS

  • Bottlenecks identified
  • Optimization strategies
  • Caching mechanisms
  • Database query optimization
  • Resource usage patterns

14. MAINTENANCE & EVOLUTION

Known Issues:

  • Current bugs or limitations
  • TODOs and FIXMEs in code

Future Considerations:

  • Planned features or improvements
  • Refactoring opportunities
  • Scalability concerns

Extension Points:

  • How to add new features
  • Plugin or extension mechanisms
  • Customization options

15. DEVELOPER GUIDE

Getting Started:

  • Prerequisites
  • Installation steps
  • Running locally
  • Common commands

Contributing:

  • How to contribute
  • Coding standards
  • PR process
  • Testing requirements

Troubleshooting:

  • Common issues and solutions
  • Debug tips
  • FAQ

Output Format

In a markdown file, please structure your documentation as follows:

  1. Executive Summary (1-2 pages)
  2. Architecture Overview (3-5 pages with diagrams)
  3. Module Documentation (per-module sections)
  4. API Reference (complete endpoint documentation)
  5. Developer Guide (setup and contribution guide)
  6. Appendices (glossary, references, etc.)

Analysis Instructions

  • Be thorough but clear: Balance comprehensiveness with readability
  • Use examples: Include code snippets where helpful
  • Visual aids: Describe diagrams where text alone is insufficient
  • Prioritize: Focus more detail on complex or critical sections
  • Be honest: Note unclear code, potential issues, or areas needing improvement
  • Cross-reference: Link related sections for easy navigation

Begin your analysis now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment