AI-powered documentation generator that creates comprehensive docs for any codebase using OpenAI GPT-4
npm install ai-documentorAI-powered documentation generator for any codebase
Generate comprehensive, beautiful documentation for your projects using advanced AI analysis. Simply run one command and get instant, professional documentation with live preview and auto-updates.


- ๐ One Command Setup - Just run ai-documentor (no flags needed)
- ๐ค AI-Powered Analysis - Uses OpenAI to understand and document your code
- ๐ Live Server - Instant preview at localhost:3000 with hot reload
- ๐ File Watching - Auto-regenerates docs when code changes
- ๐ Rich Documentation - Comprehensive coverage including:
- Project overview and architecture
- Frontend components and pages
- Backend APIs and services
- Database schema and queries
- User flows with diagrams
- Deployment guides
- Troubleshooting sections
- ๐จ Beautiful UI - Modern, responsive web interface
- ๐ GitHub Integration - Auto-update docs on push
- ๐ Real-time Progress - See what's being analyzed in real-time
``bash`
npm install -g ai-documentor
1. Get an OpenAI API key from OpenAI Platform
2. Add your API key to .env in your project root:`
bash`
OPENAI_API_KEY=your_openai_api_key_here
3. Generate documentation:
`bash`
ai-documentor
That's it! Your documentation will be generated and served at http://localhost:3000 ๐
- Node.js 16+
- OpenAI API key
- Internet connection for AI analysis
1. Codebase Analysis - Scans your entire project structure
2. AI Processing - Uses OpenAI GPT-4 to understand code patterns and purpose
3. Documentation Generation - Creates comprehensive docs in multiple sections
4. Live Serving - Hosts documentation on local server with live reload
5. Auto-Updates - Watches for file changes and regenerates automatically
Create a .documentor.json file in your project root:
`json`
{
"openaiApiKey": "your-api-key-here",
"outputDirectory": "./docs",
"watchMode": false,
"includePatterns": [
"*/.{ts,tsx,js,jsx,py,go,rs,java}",
"*/.{json,md,yml,yaml}"
],
"excludePatterns": [
"node_modules/**",
"dist/**",
"build/**",
".git/**",
"*/.test.*"
],
"frameworks": ["React", "Express", "Next.js"],
"deploymentPlatforms": ["Vercel"],
"databaseType": "PostgreSQL"
}
`bashInitialize documentor in your project
documentor init
๐ง Advanced Usage
$3
You can customize the LLM prompts in your configuration:
`json
{
"customPrompts": {
"overview": "Create a technical overview focusing on...",
"frontend": "Analyze React components with emphasis on...",
"backend": "Document APIs with special attention to...",
"database": "Explain the database schema highlighting..."
}
}
`$3
`typescript
import { CodebaseAnalyzer, DocumentationGenerator, Config } from 'documentor';const config = await Config.load();
const analyzer = new CodebaseAnalyzer(process.cwd());
const generator = new DocumentationGenerator(config);
const analysis = await analyzer.analyze();
const documentation = await generator.generate(analysis);
console.log(documentation.overview);
`$3
`yml
.github/workflows/docs.yml
name: Generate Docs
on: [push]
jobs:
docs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
with:
node-version: '18'
- run: npm install -g documentor
- run: documentor generate
env:
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
- run: # Deploy docs to your platform
`๐ค Contributing
We welcome contributions! Here's how to get started:
1. Fork the repository
2. Create a feature branch (
git checkout -b feature/amazing-feature)
3. Make your changes
4. Add tests if applicable
5. Commit your changes (git commit -m 'Add amazing feature')
6. Push to the branch (git push origin feature/amazing-feature)
7. Open a Pull Request$3
`bash
git clone https://github.com/aleclindz/documentor.git
cd documentor
npm install
npm run build
npm linkTest with a sample project
cd ../your-test-project
documentor init
`๐ Roadmap
- [ ] VS Code Extension - Generate docs directly in your editor
- [ ] Team Collaboration - Share docs with team members
- [ ] API Documentation - OpenAPI/Swagger integration
- [ ] More Languages - C#, Ruby, PHP support
- [ ] Custom Templates - Customizable output formats
- [ ] Git Integration - Automatic docs on commits
- [ ] Performance Metrics - Code quality insights
- [ ] Cloud Hosting - Optional hosted documentation
โ FAQ
Q: How much does this cost?
A: Documentor is free and open-source. You only pay for OpenAI API usage (typically $1-5 per project).
Q: Is my code sent to OpenAI?
A: Only code snippets and structure are sent to OpenAI for analysis. Your full codebase stays local.
Q: Can I use this without internet?
A: You need internet for the initial documentation generation, but the local server works offline.
Q: How accurate is the generated documentation?
A: Very accurate for code structure and flow. The LLM provides intelligent explanations based on actual code analysis.
Q: Can I customize the output?
A: Yes! You can customize prompts, templates, and output formats.
๐ Troubleshooting
$3
"OpenAI API key not found"
`bash
documentor config
Re-enter your API key
`"Failed to analyze codebase"
`bash
Check file permissions and patterns
documentor generate --verbose
`"Documentation server won't start"
`bash
Check if port is in use
documentor serve --port 3001
``- ๐ Documentation
- ๐ Report Issues
- ๐ฌ Discussions
MIT License - see LICENSE file for details.
- OpenAI for providing the GPT-4 API
- The open-source community for inspiration and feedback
- All contributors who help make this project better
---
Made with โค๏ธ by Alec Lindsay
โญ Star this repo if you find it helpful!