Skip to content

SanjayMarathi/DocGen

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

83 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

AI POWERED DOCUMENT GENERATION

DocGen is a fully offline AI-powered documentation generator that transforms programming code into structured, professional documentation using a locally running Large Language Model (LLM).

The system integrates a modern React frontend, Django REST backend, and Ollama with the Qwen2.5-Coder model β€” eliminating dependency on external APIs like OpenAI or Gemini.

🧠 Why DocGen?

Most AI documentation tools rely on paid cloud APIs. DocGen runs completely offline using a local LLM.

βœ” No API cost βœ” No internet dependency βœ” Secure local execution βœ” Full-stack architecture βœ” Production-ready implementation

✨ Features

βœ… Paste code and generate documentation instantly

βœ… Upload .py, .cpp, .java, .js files

βœ… AI-generated structured Markdown documentation

βœ… Export documentation as PDF

βœ… Export documentation as DOCX

βœ… JWT-based authentication

βœ… Document history tracking

βœ… Clean split-screen UI

βœ… Dark mode with animated background

βœ… Fully Offline (No OpenAI / Gemini required)

πŸ— System Architecture

User
↓
React Frontend (UI + API Calls)
↓
Django REST API
↓
Ollama Local Model (Qwen2.5-Coder:7B)
↓
Documentation Generator Engine
↓
Generated Output
β”œβ”€β”€ Markdown Docs
β”œβ”€β”€ PDF Export
└── DOCX Export
↓
Download to User


πŸ—οΈ Tech Stack

Layer Technology
Frontend React, Tailwind CSS, Framer Motion
Backend Django, Django REST Framework
Authentication SimpleJWT (JWT-based Auth)
AI Model Ollama + Qwen2.5-Coder:7B
PDF Engine ReportLab (Platypus)
DOCX Export python-docx

πŸ“‚ Project Structure

DocGen/
β”‚
β”œβ”€β”€ backend/
β”‚   β”œβ”€β”€ backend/
β”‚   β”‚   β”œβ”€β”€ __init__.py
β”‚   β”‚   β”œβ”€β”€ settings.py
β”‚   β”‚   β”œβ”€β”€ urls.py
β”‚   β”‚   β”œβ”€β”€ asgi.py
β”‚   β”‚   └── wsgi.py
β”‚   β”‚
β”‚   β”œβ”€β”€ generator/
β”‚   β”‚   β”œβ”€β”€ migrations/
β”‚   β”‚   β”œβ”€β”€ admin.py
β”‚   β”‚   β”œβ”€β”€ apps.py
β”‚   β”‚   β”œβ”€β”€ models.py
β”‚   β”‚   β”œβ”€β”€ serializers.py
β”‚   β”‚   β”œβ”€β”€ views.py
β”‚   β”‚   β”œβ”€β”€ urls.py
β”‚   β”‚   └── utils.py
β”‚   β”‚
β”‚   β”œβ”€β”€ manage.py
β”‚   └── requirements.txt
β”‚
β”œβ”€β”€ frontend/
β”‚   β”œβ”€β”€ public/
β”‚   β”‚   β”œβ”€β”€ index.html
β”‚   β”‚   β”œβ”€β”€ favicon.ico
β”‚   β”‚   └── manifest.json
β”‚   β”‚
β”‚   β”œβ”€β”€ src/
β”‚   β”‚   β”œβ”€β”€ components/
β”‚   β”‚   β”‚   β”œβ”€β”€ Login.jsx
β”‚   β”‚   β”‚   β”œβ”€β”€ Dashboard.jsx
β”‚   β”‚   β”‚   β”œβ”€β”€ Editor.jsx
β”‚   β”‚   β”‚   └── History.jsx
β”‚   β”‚   β”‚
β”‚   β”‚   β”œβ”€β”€ services/
β”‚   β”‚   β”‚   └── api.js
β”‚   β”‚   β”‚
β”‚   β”‚   β”œβ”€β”€ App.js
β”‚   β”‚   β”œβ”€β”€ index.js
β”‚   β”‚   └── App.css
β”‚   β”‚
β”‚   β”œβ”€β”€ package.json
β”‚   β”œβ”€β”€ tailwind.config.js
β”‚   └── postcss.config.js
β”‚
β”œβ”€β”€ .gitignore
└── README.md

βš™οΈ Installation & Setup Guide

πŸ”Ή Prerequisites

Python 3.10+

Node.js + npm

Ollama installed locally

1️⃣ Clone Repository

git clone https://github.com/SanjayMarathi/DocGen.git
cd DocGen

2️⃣ Setup Ollama (Local LLM)

Pull the model and start Ollama:

ollama pull qwen2.5-coder:7b
ollama serve


Ollama runs at:

http://localhost:11434

3️⃣ Backend Setup (Django)

cd backend
python -m venv venv

β–Ά Activate Virtual Environment

Windows (PowerShell)

.\venv\Scripts\activate


Mac/Linux (Bash)

source venv/bin/activate

β–Ά Install Dependencies

pip install -r requirements.txt


If requirements.txt is not available:

pip install django djangorestframework djangorestframework-simplejwt django-cors-headers requests reportlab python-docx wikipedia

β–Ά Apply Migrations

python manage.py migrate

β–Ά Run Backend Server

python manage.py runserver 8000

Backend URL:

http://127.0.0.1:8000

4️⃣ Frontend Setup (React)

cd frontend
npm install
npm start

Frontend URL:

http://localhost:3000

πŸ”Œ API Endpoints

Method	Endpoint	Description
POST	/api/generate/	Generate streaming documentation
POST	/api/pdf/	Export generated documentation as PDF
POST	/api/docx/	Export generated documentation as DOCX

πŸ” Authentication

JWT-based authentication (SimpleJWT)

Token-based API communication

Document history linked to user account

πŸ“„ PDF & DOCX Generation

PDF export uses ReportLab Platypus Engine
DOCX export uses python-docx

Provides:

Structured headings

Code block formatting

Professional layout

Instant download

πŸ§ͺ Quick Test

Start Ollama

Start Backend

Start Frontend

Paste or upload code

Click Generate Documentation

Click Export PDF / DOCX

⚠️ Troubleshooting

Model not responding

ollama list


If model missing:

ollama pull qwen2.5-coder:7b

## CORS Issues

Already enabled in settings.py:

CORS_ALLOW_ALL_ORIGINS = True

## Port Conflict

Update ports in:

frontend/src/App.js

backend/generator/views.py

πŸš€ Future Improvements

Markdown live preview panel

Multi-language documentation templates

Docker containerization

Role-based access control

Cloud deployment version.

About

An AI-assisted system that automatically generates technical documentation, API references, and release notes by analyzing source code and Git commit history.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors