AutoDoc is an intelligent, AI-powered platform that automatically analyzes source code and APIs to generate comprehensive, human-readable documentation. It combines static code analysis with Large Language Models (LLMs) to create detailed documentation, examples, diagrams, and explanations that help developers understand codebases quickly.
- π Automatic Code Analysis: Parses and analyzes multiple programming languages
- π€ AI-Powered Explanations: Uses OpenAI GPT-4 or Anthropic Claude to generate intelligent documentation
- π Multi-Format Output: Generates Markdown documentation with code examples and diagrams
- π₯οΈ CLI & API: Command-line tool for local use and REST API for integration
- π Project Insights: Analyzes project structure, dependencies, and code patterns
- πΎ History Tracking: Stores documentation versions and analysis history in SQLite
- π³ Docker Ready: Fully containerized for easy deployment
AutoDoc follows a microservices architecture with two main components:
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β Client Layer β
β ββββββββββββββββ ββββββββββββββββ ββββββββββββββββ β
β β CLI Tool β β REST API β β Web UI β β
β β (Commander) β β (Express) β β (Future) β β
β ββββββββββββββββ ββββββββββββββββ ββββββββββββββββ β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β
ββββββββββββββββββββΌβββββββββββββββββββββ
β β β
βΌ βΌ βΌ
ββββββββββββββββ ββββββββββββββββ ββββββββββββββββ
β Node.js β β Python β β SQLite β
β Backend βββββ€ AI Service β β Database β
β β β β β β
β - Analyzers β β - LLM APIs β β - Analyses β
β - Parsers β β - Diagram β β - Docs β
β - Generatorsβ β - Generationβ β - History β
ββββββββββββββββ ββββββββββββββββ ββββββββββββββββ
β β
β β
ββββββββββββββββββββ
β
βΌ
ββββββββββββββββ
β Source Code β
β Repository β
ββββββββββββββββ
- Purpose: Core analysis engine and API server
- Responsibilities:
- File ingestion and parsing
- Project structure analysis
- Dependency detection
- Code element extraction (functions, classes, imports, etc.)
- Documentation generation orchestration
- Database operations
- REST API endpoints
- Purpose: Intelligent documentation enhancement
- Responsibilities:
- LLM integration (OpenAI/Anthropic)
- Natural language documentation generation
- Code explanations and summaries
- Mermaid diagram generation
- Enhanced documentation quality
- Purpose: Data persistence
- Stores:
- Project analysis results
- Generated documentation
- Analysis history and metadata
- Version tracking
1. User Input (CLI/API)
β
2. Node.js Backend receives project path
β
3. Project Analyzer scans directory structure
β
4. Code Parser extracts code elements per file
β
5. Dependency Analyzer detects dependencies
β
6. Analysis stored in SQLite database
β
7. Documentation Generator creates base markdown
β
8. Python AI Service enhances with LLM (optional)
β
9. Final documentation stored and returned
AutoDoc/
βββ src/ # TypeScript source code
β βββ index.ts # Main Express server entry point
β βββ analyzers/ # Code analysis modules
β β βββ projectAnalyzer.ts # Main project analysis orchestrator
β β βββ dependencyAnalyzer.ts # Dependency detection (npm, pip, go, etc.)
β β βββ structureAnalyzer.ts # Directory structure and file analysis
β βββ parsers/ # File parsing utilities
β β βββ codeParser.ts # Multi-language code parser
β βββ generators/ # Documentation generators
β β βββ docGenerator.ts # Markdown documentation generator
β βββ database/ # Database operations
β β βββ databaseManager.ts # SQLite operations and schema
β βββ types/ # TypeScript type definitions
β βββ index.ts # Comprehensive type system
β
βββ python-service/ # Python AI service
β βββ app.py # Flask application and LLM service
β βββ requirements.txt # Python dependencies
β βββ Dockerfile # Python service containerization
β βββ README.md # Python service documentation
β
βββ bin/ # CLI executable
β βββ autodoc.ts # Command-line interface entry point
β
βββ tests/ # Test files
β βββ core.test.ts # Core functionality tests
β
βββ templates/ # Documentation templates (future)
βββ output/ # Generated documentation output
βββ database/ # SQLite database files
β βββ autodoc.db # Main database file
β
βββ Dockerfile # Node.js backend containerization
βββ docker-compose.yml # Multi-service orchestration
βββ docker.sh # Docker helper scripts
βββ .dockerignore # Docker build exclusions
β
βββ package.json # Node.js dependencies and scripts
βββ tsconfig.json # TypeScript configuration
βββ .eslintrc.json # ESLint configuration
βββ .babelrc # Babel configuration
βββ env.example # Environment variables template
β
βββ README.md # This file
- Runtime: Node.js 18+
- Language: TypeScript 5.3+
- Framework: Express.js 4.18+
- Database: SQLite3
- Key Libraries:
commander- CLI interfacechalk- Terminal colorsora- Spinners and progressfs-extra- Enhanced file operationsglob- File pattern matchingmulter- File uploadsaxios- HTTP requests
- Runtime: Python 3.11+
- Framework: Flask 2.3+
- Key Libraries:
openai- OpenAI GPT integrationanthropic- Claude API integrationrequests- HTTP clientflask-cors- CORS support
- Containerization: Docker & Docker Compose
- Database: SQLite (file-based, no server required)
- Deployment: Multi-container architecture
# Clone the repository
git clone https://github.com/srdarkser/autodoc.git
cd autodoc
# Install dependencies
npm install
# Build the project
npm run build
# (Optional) Install globally for CLI access
npm install -g .# Build and start all services
docker-compose up -d
# Check service status
docker-compose ps
# View logs
docker-compose logs -f
# Stop services
docker-compose downSimple CLI Usage:
# Analyze any project on your system
autodoc analyze /path/to/your/project
# Example: Document a React app
autodoc analyze ~/projects/my-react-app --output ./documentation
# Example: Document current directory
cd ~/my-project
autodoc analyze . --output ./docsUsing REST API:
# Start the server
autodoc serve # or: docker-compose up -d
# Analyze via API
curl -X POST http://localhost:3000/api/analyze \
-H "Content-Type: application/json" \
-d '{"projectPath": "/path/to/your/project"}'π For detailed usage instructions, see USAGE.md
# Install Node.js dependencies
npm install
# Install Python dependencies
cd python-service
pip install -r requirements.txt
cd ..
# Build TypeScript
npm run build
# Start backend server
npm start
# In another terminal, start Python AI service
cd python-service
python app.py# Initialize AutoDoc configuration
autodoc init
# Analyze a project
autodoc analyze ./my-project
# Analyze with options
autodoc analyze ./my-project --output ./docs --include-tests
# Start the server
autodoc serve --port 3000| Method | Endpoint | Description |
|---|---|---|
GET |
/health |
Health check |
POST |
/api/analyze |
Analyze a project |
POST |
/api/generate-docs |
Generate documentation |
GET |
/api/analyses |
Get all analyses |
GET |
/api/docs/:id |
Get documentation by ID |
| Method | Endpoint | Description |
|---|---|---|
GET |
/health |
Health check |
POST |
/api/generate-docs |
Generate AI-enhanced documentation |
POST |
/api/analyze-code |
Analyze code snippets |
POST |
/api/generate-diagram |
Generate Mermaid diagrams |
# Analyze a project
curl -X POST http://localhost:3000/api/analyze \
-H "Content-Type: application/json" \
-d '{
"projectPath": "/path/to/project",
"options": {
"includeTests": false,
"maxFileSize": 1048576
}
}'
# Generate documentation
curl -X POST http://localhost:3000/api/generate-docs \
-H "Content-Type: application/json" \
-d '{
"analysisId": "analysis-id-here",
"template": "default",
"options": {
"includeDiagrams": true,
"includeExamples": true
}
}'AutoDoc supports analysis of the following languages:
- β JavaScript (ES6+)
- β TypeScript
- β Python 3
- β Java
- β Go
- β Rust
- πΆ C/C++
- πΆ C#
- πΆ PHP
- πΆ Ruby
- πΆ Swift
- πΆ Kotlin
- β Node.js (package.json, package-lock.json, yarn.lock)
- β Python (requirements.txt, pyproject.toml, setup.py)
- β Java (pom.xml, build.gradle)
- β Go (go.mod, go.sum)
- β Rust (Cargo.toml, Cargo.lock)
AutoDoc supports multiple LLM providers for enhanced documentation:
export OPENAI_API_KEY="sk-..."
export LLM_PROVIDER="openai"export ANTHROPIC_API_KEY="sk-ant-..."
export LLM_PROVIDER="anthropic"AutoDoc automatically falls back to mock documentation generation if no API keys are provided.
- Multi-file Analysis: Scans entire projects recursively
- Pattern Detection: Identifies functions, classes, interfaces, types, etc.
- Import Tracking: Maps dependencies between files
- Comment Extraction: Captures and preserves documentation comments
- Structure Mapping: Generates project hierarchy diagrams
- Markdown Format: Clean, developer-friendly markdown output
- Code Examples: Extracts and formats code snippets
- Mermaid Diagrams: Generates flowcharts and class diagrams
- API Documentation: Auto-generates API reference from code
- Usage Examples: Creates example usage patterns
- History Tracking: Stores all analysis runs for comparison
- Version Control: Tracks documentation versions
- Custom Templates: Support for custom documentation templates
- Batch Processing: Analyze multiple projects simultaneously
- Export Formats: Markdown, HTML (future), PDF (future)
Create a .env file based on env.example:
# LLM Configuration
OPENAI_API_KEY=your_openai_key
ANTHROPIC_API_KEY=your_anthropic_key
LLM_PROVIDER=openai
# Service Configuration
PORT=3000
PYTHON_SERVICE_PORT=5000
NODE_ENV=development
# Database
DATABASE_PATH=database/autodoc.db
# Output
OUTPUT_DIRECTORY=./docs
TEMPLATE=default
FORMAT=markdownAfter running autodoc init, you can customize .autodoc.json:
{
"version": "1.0.0",
"analysis": {
"includePatterns": ["**/*.js", "**/*.ts", "**/*.py"],
"excludePatterns": ["node_modules/**", ".git/**"],
"maxFileSize": 1048576,
"includeTests": false,
"includeComments": true
},
"output": {
"directory": "./docs",
"format": "markdown",
"template": "default",
"includeDiagrams": true
}
}- Node.js 18+ and npm
- Python 3.11+ and pip
- Docker and Docker Compose (optional)
# Install all dependencies
npm install
cd python-service && pip install -r requirements.txt && cd ..
# Run TypeScript in watch mode
npm run dev:watch
# Run Python service
npm run python:start
# Run linting
npm run lint
npm run lint:fix
# Run tests
npm test
# Build for production
npm run build- TypeScript: Strict mode enabled with comprehensive type checking
- Error Handling: Try-catch blocks with proper error responses
- Logging: Console logging with structured output
- Validation: Input validation on all API endpoints
- Type Safety: Complete TypeScript coverage with no
anytypes
# Build images
docker-compose build
# Start services
docker-compose up -d
# View logs
docker-compose logs -f
# Stop services
docker-compose down- Environment Variables: Set secure API keys
- Database Backup: Regularly backup SQLite database
- Resource Limits: Configure Docker resource limits
- Reverse Proxy: Use nginx for production
- SSL/TLS: Enable HTTPS for API endpoints
- Monitoring: Set up logging and monitoring
- Open Source Projects: Generate comprehensive docs for GitHub repositories
- Enterprise Codebases: Document large, complex projects automatically
- API Documentation: Generate API docs from code analysis
- Code Reviews: Understand project structure before reviews
- Developer Onboarding: Help new developers understand codebases quickly
- Compliance: Generate documentation for regulatory requirements
- Knowledge Transfer: Preserve institutional knowledge
- Technical Writing: Base content for technical writers
We welcome contributions! Please follow these steps:
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Make your changes
- Add tests if applicable
- Commit your changes (
git commit -m 'feat: add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
- OpenAI and Anthropic for LLM APIs
- Express.js and Flask communities
- All contributors and users of AutoDoc
Author: Sushant R. Dangal