An intelligent tool that automatically generates comprehensive documentation for GitHub repositories using AI. This application analyzes your codebase, understands its architecture, and generates both README files and developer guides with detailed technical insights.
- Automatic Repository Analysis: Clones and deeply analyzes GitHub repositories
- AI-Powered Documentation Generation: Uses OpenRouter API to generate intelligent, context-aware documentation
- Dual Document Generation: Creates both README and Developer Guide documents
- PDF Export: Download generated documentation as PDF files
- Job Queue System: Efficient background processing with BullMQ and Redis
- Real-time Progress Tracking: Monitor documentation generation progress in real-time
- Dark/Light Mode UI: Modern, responsive frontend with theme support
- Tech Stack Detection: Automatically identifies frameworks, languages, and technologies used
- Framework: Express.js
- Runtime: Node.js
- Database: MySQL
- Queue System: BullMQ with Redis
- API Integration: OpenRouter (AI API)
- Repository Handling: simple-git
- PDF Generation: PDFKit
- Framework: React 19
- Build Tool: Vite
- Styling: Tailwind CSS
- Markdown Rendering: react-markdown with GFM support
- Icons: Lucide React
project/
βββ backend/
β βββ src/
β β βββ app.js # Express app configuration
β β βββ server.js # Server entry point
β β βββ config/
β β β βββ db.js # MySQL pool configuration
β β β βββ redis.js # Redis connection
β β β βββ env.js # Environment configuration
β β βββ constants/
β β β βββ jobStatus.js # Job status constants
β β βββ controllers/
β β β βββ job.controller.js # Job API endpoints
β β βββ routes/
β β β βββ job.routes.js # Job routes
β β βββ services/
β β β βββ job.service.js # Job business logic
β β βββ queues/
β β β βββ doc.queue.js # BullMQ queue setup
β β βββ workers/
β β β βββ doc.worker.js # Background job processor
β β βββ utils/
β β βββ fileUtils.js # File system utilities
β β βββ openRouterAPI.js # AI documentation generation
β β βββ pdfGenerator.js # PDF export functionality
β β βββ repoAnalysis.js # Repository analysis logic
β β βββ splitDocuments.js # Document splitting utilities
β βββ package.json
β
βββ frontend/
βββ src/
β βββ App.jsx # Main application component
β βββ api/
β β βββ jobApi.js # Job API client
β βββ components/
β β βββ MarkdownRenderer.jsx # Markdown rendering component
β βββ utils/
β β βββ downloadMarkdown.js # File download utilities
β βββ App.css # Global styles
β βββ index.css # Reset styles
β βββ main.jsx # React entry point
βββ public/ # Static assets
βββ index.html # HTML entry point
βββ vite.config.js # Vite configuration
βββ tailwind.config.js # Tailwind CSS configuration
βββ postcss.config.js # PostCSS configuration
βββ package.json
The entire application stack can be run with a single command using Docker Compose. This is the recommended way to run the project locally.
-
Clone the repository
git clone https://github.com/mahek395/DocGen-ai.git cd DocGen-ai -
Create a root
.envfile with your database credentialsDB_PASSWORD=your_mysql_password DB_NAME=ai_doc_generator
-
Create
backend/.envwith all required variablesPORT=5000 DB_HOST=mysql DB_USER=root DB_PASSWORD=your_mysql_password DB_NAME=ai_doc_generator REDIS_HOST=redis REDIS_PORT=6379 CORS_ORIGIN=http://localhost OPENROUTER_API_KEY=your_openrouter_api_key
-
Start all services
docker compose up
The app will be available at http://localhost.
| Service | Description | Port |
|---|---|---|
| frontend | React app served via Nginx | 80 |
| backend | Express API server | 5000 |
| worker | BullMQ background job processor | - |
| mysql | Job and document storage | 3306 |
| redis | Queue backend for BullMQ | 6379 |
- MySQL and Redis health checks ensure the backend and worker only start once the databases are ready
- The worker runs as a separate container using the same backend image, overriding the start command
- On first run,
init.sqlis automatically executed to create the required database schema - To reset all data and reinitialize the database:
docker compose down -v && docker compose up
- Node.js (v20 or higher)
- MySQL (v8 or higher) - for job and document storage
- Redis (v6 or higher) - for queue management
- Git - for repository cloning
- OpenRouter API Key - for AI documentation generation
git clone https://github.com/mahek395/DocGen-ai.git
cd DocGen-aicd backend
npm installCreate a .env file in the backend directory:
# MySQL Configuration
DB_HOST=localhost
DB_USER=root
DB_PASSWORD=your_password
DB_NAME=ai_doc_generator
# Redis Configuration
REDIS_HOST=localhost
REDIS_PORT=6379
# OpenRouter API
OPENROUTER_API_KEY=your_openrouter_api_key
# Server Port
PORT=5000
# CORS
CORS_ORIGIN=http://localhost:5173cd ../frontend
npm installCreate a .env.local file (optional, for custom API endpoint):
VITE_API_URL=http://localhost:5000Create the MySQL database and tables:
CREATE DATABASE IF NOT EXISTS ai_doc_generator;
USE ai_doc_generator;
CREATE TABLE IF NOT EXISTS jobs (
id CHAR(36) PRIMARY KEY,
repo_url TEXT NOT NULL,
status ENUM('pending', 'processing', 'completed', 'failed') DEFAULT 'pending',
progress INT DEFAULT 0,
result_path TEXT,
error_message TEXT,
result LONGTEXT,
readme_md LONGTEXT,
developer_guide_md LONGTEXT,
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP
);Terminal 1 - Backend Server:
cd backend
npm run devTerminal 2 - Background Worker:
cd backend
npm run workerTerminal 3 - Frontend:
cd frontend
npm run devThe frontend will run on http://localhost:5173
Endpoint: POST /api/jobs
Request Body:
{
"repoUrl": "https://github.com/username/repository"
}Response:
{
"jobId": "uuid-string",
"status": "pending"
}Endpoint: GET /api/jobs/:jobId
Response:
{
"id": "uuid-string",
"status": "completed",
"progress": 100,
"documents": {
"readme": "# Project README...",
"developerGuide": "# Developer Guide..."
}
}Endpoint: GET /api/jobs/:jobId/developer-guide.pdf
Response: Binary PDF file
- Job Creation: User submits a GitHub repository URL
- Queue Processing: Job is added to BullMQ queue with Redis backend
- Repository Cloning: Background worker clones the repository
- Analysis Phase:
- Detects repository type and tech stack
- Identifies entry points and routing
- Analyzes database schemas
- Extracts environment variables
- Generates folder structure tree
- AI Documentation: OpenRouter API generates comprehensive documentation
- Document Storage: Generated documents are stored in MySQL
- Frontend Display: User views and can download the generated documentation
npm start- Start production servernpm run dev- Start development server with auto-reloadnpm run worker- Start background job worker
npm run dev- Start development servernpm run build- Build for productionnpm run lint- Run ESLintnpm run preview- Preview production build
- Secure your
.envfile - never commit credentials to version control - Use strong MySQL passwords
- Keep your OpenRouter API key confidential
- Validate all incoming repository URLs
- Implement rate limiting for API endpoints in production
- Use HTTPS in production environment
- Ensure MySQL is running
- Verify credentials in
.envfile - Check database exists and tables are created
- Ensure Redis is running on the specified host/port
- Check Redis configuration in
config/redis.js
- Verify API key is valid and has available credits
- Check API rate limits haven't been exceeded
- Ensure repository is accessible and public
- Check CORS settings in
backend/src/app.js - Verify backend is running on correct port
- Check frontend environment variables
DB_HOST- MySQL host (usemysqlwhen running with Docker)DB_USER- MySQL usernameDB_PASSWORD- MySQL passwordDB_NAME- Database nameREDIS_HOST- Redis host (userediswhen running with Docker)REDIS_PORT- Redis port (default: 6379)OPENROUTER_API_KEY- Your OpenRouter API keyPORT- Server port (default: 5000)CORS_ORIGIN- Allowed frontend origin
The system performs deep analysis including:
- Technology stack detection (frameworks, libraries, languages)
- Entry point identification
- API route discovery
- Database schema analysis
- Authentication mechanism detection
- Environment variable extraction
- Project folder structure mapping
Generated documentation includes:
- README: Quick start guide, features, installation, usage
- Developer Guide: Architecture overview, code structure, module descriptions, API documentation
Users can monitor job progress with percentage completion and current processing step:
- Initializing job
- Cloning repository
- Analyzing codebase
- Understanding architecture
- Generating documentation
- Finalizing output
ISC
Contributions are welcome! Please feel free to submit a Pull Request.
For issues and questions, please open an issue on GitHub.
Built with β€οΈ for developers who love documentation