Live demo: https://docgen-ansh.streamlit.app
Upload your code. Docgen writes the documentation, reviews the code, drafts a README and answers your questions about it.
Problem: undocumented code is slow to understand, slow to review and painful to hand over. Writing docstrings by hand is repetitive, so it usually doesn't happen.
Solution: Docgen finds every function in your code, asks an AI model to explain what it actually does, and writes that explanation back into the code in the right format. It works on Python, Java, JavaScript, C and C++, and accepts single files or a whole ZIP.
| Tab / feature | What it gives you |
|---|---|
| Documentation Engine | Docstrings for every undocumented function, shown next to the original code. Download the result. |
| Quality Audit | An AI code review: bugs, security, performance and best practices, with line numbers, suggested fixes, a chart and an A to D health grade. |
| README Architect | A README draft generated from your code, with preview and download. |
| Project Map | An interactive 3D map of your files, classes and functions, showing which functions Docgen documented and which already had docs. |
| Code Chat (sidebar) | Ask questions about your code, the generated docs and the audit findings. |
Docstring styles: Google, NumPy, Sphinx for Python. Javadoc for Java, JSDoc for JavaScript, Doxygen for C and C++.
- Open the live demo: https://docgen-ansh.streamlit.app
- Click Try an example (or upload your own files or a ZIP).
- Look at the original and documented code side by side.
- Open Quality Audit and click Run audit.
- Open Project Map to see the 3D graph.
- Ask a question in the sidebar chat, for example "Which function is the riskiest?".
- Upload: files or a ZIP (up to 25 files per run).
- Find: every function and method is located. Python uses the real syntax tree (
ast); other languages use text patterns. - Describe: each function is turned into a standard description: name, arguments, types, return type and code.
- Write: a carefully built prompt is sent to the AI model, and the answer is cleaned up. If the AI fails or is switched off, a template docstring is used instead, so the run never stops.
- Insert: the docstring is placed back into the code.
flowchart TD
UI["Streamlit dashboard<br/>app/streamlit_app.py"] --> CORE
API["FastAPI service (optional)<br/>app/api/main.py"] --> CORE
CORE["Core engine<br/>app/core"] --> LLM["Groq API<br/>openai/gpt-oss-120b"]
- Dashboard: the website people use. It calls the core engine directly.
- Core engine (
app/core): all the logic: finding functions, building prompts, calling the AI, inserting docstrings, review, README and chat. - AI model: OpenAI's open-weight
gpt-oss-120b, served by Groq. Every AI call goes through one file (ai_docstring_engine.py), so changing the model is a one-line edit. - FastAPI service (optional): exposes the same engine over HTTP for scripts and other apps. The dashboard does not need it.
| Purpose | Technology |
|---|---|
| Website | Streamlit |
| Charts and 3D map | Plotly, pandas |
| Optional API | FastAPI, Uvicorn, Pydantic |
| AI model | openai/gpt-oss-120b via the Groq API |
| Code analysis | Python ast module, regular expressions |
| Settings and monitoring | python-dotenv, psutil |
Automated-Python-Docstring-Generator-T-B/
├── app/
│ ├── streamlit_app.py # The website
│ ├── api/
│ │ └── main.py # Optional web API
│ └── core/ # The engine
│ ├── parser.py # Finds functions
│ ├── ai_engine.py # Describes each function in a standard format
│ ├── prompt_builder.py # Detects language, builds the AI instructions
│ ├── ai_docstring_engine.py # Talks to Groq; holds the model name
│ ├── inserter.py # Puts docstrings back into the code
│ ├── docstring_gen.py # Backup: template docstrings without AI
│ ├── code_reviewer.py # AI code review
│ ├── chat_engine.py # Code chat
│ └── readme_generator.py # README draft
├── .streamlit/config.toml # Theme
├── requirements.txt
├── LICENSE
└── README.md
You need Python 3.9+, Git, and a free Groq API key from console.groq.com.
git clone https://github.com/Xynash/Automated-Python-Docstring-Generator-T-B.git
cd Automated-Python-Docstring-Generator-T-B
python -m venv venvActivate the environment:
# Windows (PowerShell)
venv\Scripts\Activate.ps1
# macOS / Linux
source venv/bin/activateInstall and add your key:
pip install -r requirements.txtCreate a file named .env in the project folder:
GROQ_API_KEY=your_key_hereStart the website:
python -m streamlit run app/streamlit_app.pyOpen http://localhost:8501. On Streamlit Cloud, put GROQ_API_KEY under Secrets instead. Never commit .env.
Start it:
python -m uvicorn app.api.main:app --reloadInteractive docs: http://127.0.0.1:8000/docs
POST /process accepts:
| Field | Default | Values |
|---|---|---|
code |
required | The source code as text |
style |
google |
google, numpy, sphinx (Python only) |
task |
document |
document, review, readme |
language |
python |
python, java, javascript, cpp |
Example (PowerShell):
$body = @{ code = "def add(a, b):`n return a + b"; style = "google"; task = "document"; language = "python" } | ConvertTo-Json
Invoke-RestMethod -Uri http://127.0.0.1:8000/process -Method Post -ContentType "application/json" -Body $bodyWhere the answer appears in the response: Python documentation in documented_code, Python review in data, Python README in content, and any other language in output. Every response also includes timing and memory telemetry.
- tree-sitter parsing for all languages
- Comment-preserving insertion for Python
- Faster processing with parallel AI requests
- Unit tests and CI
- Retrieval-based chat for large codebases
| Problem | Fix |
|---|---|
GROQ_API_KEY not found |
Create the .env file with your key (or set it in Streamlit Secrets), then restart. |
| Some functions got template docstrings | The AI request failed for them. Check your key and rate limit, then run again. |
ModuleNotFoundError |
Activate the virtual environment and run pip install -r requirements.txt. |
Attribute "app" not found (API) |
Run uvicorn from the project folder with app.api.main:app. |
422 Unprocessable Entity (API) |
Send JSON with at least a code text field. |
- Work on your own branch:
git checkout -b member-name - Commit small, clear changes:
git commit -m "Add async review endpoint" - Push your branch:
git push origin member-name - Open a Pull Request. Never push directly to
main; every change is reviewed first.
- Ansh Sharma (Team Lead)
- Sreya Merin Sam
- Kasa Navya Sri Durga
- Vattikoti Pooja
Streamlit, FastAPI and Groq, the open-source Python community, and our Infosys Springboard mentors.
Released under the MIT License.