Skip to content

ptraxzy/docforge

Repository files navigation

DocForge

CI License: MIT Contributions welcome

AI-Powered Documentation Generator β€” Open Source & Self-Hostable

DocForge is a production-ready documentation generation tool that uses AI to automatically scan your codebase and create high-quality documentation. It features a Node.js CLI client with a premium static website builder and a FastAPI backend server compatible with any OpenAI-compatible LLM.

Privacy by default: DocForge now points to http://localhost:8000 unless you explicitly configure another endpoint. Review your chosen AI provider's data policy before sending source code to it.


Key Features

  • 🌐 Multi-Language Support: Scans and documents JavaScript, TypeScript, Python, Go, Rust, Java, PHP, C++, C#, Kotlin, Swift, and more.
  • πŸ€– Bring Your Own AI: Seamlessly connect to Ollama, vLLM, LM Studio, OpenAI, OpenRouter, or Groq.
  • ⚑ Framework Detection & Integration: Automatically detects Laravel, Next.js, Vite/React, or Static projects and injects custom-tailored documentation pages (Docs.tsx, docs.blade.php, or static index.html) directly.
  • πŸ“‚ Website Builder: Builds a premium documentation site from Markdown files featuring:
    • Nested Sidebar Tree Navigation with custom guide lines.
    • Active State Highlights synced across scrolling, manual clicks, and Next/Previous navigation buttons.
    • Clean Expanded Layout with full responsiveness and copy-to-clipboard buttons on code snippets.
  • πŸš€ Docker Ready: Easy self-hosting with preconfigured docker-compose.yml.

Quick Start

Option 1: Run instantly with npx (No Setup Required)

Generate documentation for your project in seconds without installing anything:

# Generate markdown documentation files
npx @ultramaxoo/docforge generate

# Build a premium documentation site
npx @ultramaxoo/docforge build-site

Option 2: Global Installation

Install globally on your system to use the CLI directly:

# Install CLI
npm install -g @ultramaxoo/docforge

# Initialize docforge config in your project
docforge init

# Generate docs
docforge generate

# Build docs site
docforge build-site

CLI Command Reference

1. docforge init

Initializes a local configuration file .docforge/config.json and a placeholder documentation folder.

2. docforge generate [path]

Scans the directory files and generates markdown docs.

  • -o, --output <dir>: Output directory (default: ./)
  • -s, --server <url>: Target server URL override
  • -i, --include <patterns...>: File patterns to include
  • -e, --exclude <patterns...>: File patterns to exclude
  • --readme / --no-readme: Toggle README.md generation
  • --api / --no-api: Toggle API.md generation
  • --architecture / --no-architecture: Toggle ARCHITECTURE.md generation
  • --changelog / --no-changelog: Toggle CHANGELOG.md generation

3. docforge build-site

Compiles generated markdown files into a premium docs site matching your local framework.

  • -i, --input <dir>: Directory containing markdown files (default: ./docs)
  • -o, --output <dir>: Output directory for static HTML pages (default: ./docs-site)
  • --compile-only: Compile existing markdown files directly without calling the AI

4. docforge serve

Starts the DocForge server locally for self-hosting.

  • -p, --port <port>: Port to listen on (default: 8000)
  • --ai-url <url>: AI endpoint base URL
  • --ai-model <model>: AI model name
  • --ai-key <key>: AI provider API key (optional)

5. docforge set-server <url> & docforge get-server

Sets or displays the default DocForge API backend server URL.


Self-Hosting & Docker Setup

You can run the full server stack locally using Docker Compose:

# Start server + Ollama AI service
docker compose up -d

# Pull an AI model to your local Ollama instance
docker compose exec ollama ollama pull llama3

# Configure CLI to point to your local server
docforge set-server http://localhost:8000

Server Environment Variables (.env)

Configure the FastAPI server by creating a .env file under server/:

AI_BASE_URL=http://localhost:11434/v1  # OpenAI-compatible API endpoint
AI_MODEL=llama3                        # Model identifier
AI_API_KEY=your-api-key-here           # Optional key for cloud providers
MAX_TOKENS=4000
TEMPERATURE=0.7
HOST=0.0.0.0
PORT=8000
RATE_LIMIT_PER_MINUTE=10
CORS_ORIGINS=*

Supported AI Providers

DocForge works out of the box with any OpenAI-compatible API:

Provider Base URL Note
Ollama http://localhost:11434/v1 Free & local
vLLM http://localhost:8000/v1 High-performance
LM Studio http://localhost:1234/v1 GUI local runner
OpenAI https://api.openai.com/v1 Cloud API
OpenRouter https://openrouter.ai/api/v1 Aggregated services
Groq https://api.groq.com/openai/v1 Fast inference

Community and project health

DocForge is built in public and welcomes maintainers, documentation writers, and developers.

Useful contributions include provider setup examples, tests, framework templates, documentation improvements, and fixes that make self-hosting easier.


Project Structure

docforge/
β”œβ”€β”€ server/                 # FastAPI server (AI processing)
β”‚   β”œβ”€β”€ main.py             # App entry, middleware, logging
β”‚   β”œβ”€β”€ config.py           # Environment config + validation
β”‚   β”œβ”€β”€ routes/
β”‚   β”‚   β”œβ”€β”€ generate.py     # POST /generate
β”‚   β”‚   β”œβ”€β”€ repo.py         # POST /generate-from-repo
β”‚   β”‚   └── health.py       # GET /health (with AI status)
β”‚   β”œβ”€β”€ services/
β”‚   β”‚   β”œβ”€β”€ ai_provider.py  # Unified OpenAI-compatible client
β”‚   β”‚   β”œβ”€β”€ doc_generator.py # Prompt building + parsing
β”‚   β”‚   └── repo_downloader.py
β”‚   β”œβ”€β”€ models/
β”‚   β”‚   └── schemas.py      # Pydantic models + validators
β”‚   β”œβ”€β”€ Dockerfile
β”‚   └── requirements.txt
β”‚
β”œβ”€β”€ client/                 # Node.js CLI
β”‚   β”œβ”€β”€ src/
β”‚   β”‚   β”œβ”€β”€ index.js        # CLI command registration
β”‚   β”‚   β”œβ”€β”€ commands/
β”‚   β”‚   β”‚   β”œβ”€β”€ generate.js  # Doc generation engine
β”‚   β”‚   β”‚   β”œβ”€β”€ buildSite.js # Site compilation engine
β”‚   β”‚   β”‚   β”œβ”€β”€ init.js
β”‚   β”‚   β”‚   └── serve.js
β”‚   β”‚   └── templates/
β”‚   β”‚       β”œβ”€β”€ react-component.tsx # React template (Next.js/Vite)
β”‚   β”‚       β”œβ”€β”€ laravel.blade.php   # Laravel Blade template
β”‚   β”‚       └── static.html         # Static HTML/Alpine.js template
β”‚   └── package.json
β”‚
β”œβ”€β”€ docker-compose.yml
└── README.md

License

MIT

About

Open-source, self-hostable AI documentation generator for codebases

Topics

Resources

Code of conduct

Contributing

Security policy

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages