How sourav-maji/auto-doc-generator works
Project type and purpose
• This is a Node.js backend service (“auto-doc-generator”) whose sole purpose is to automatically update project documentation on every code change.
• It exposes a CLI or script entry point (via npm scripts) that:
1. Computes a git diff
2. Feeds the diff and existing docs into Google Gemini AI
3. Receives a Markdown update
4. Writes to docs/UPDATED_DOCUMENTATION.md
5. Optionally commits & pushes the updated docs
File structure
• Top-level files:
• app.js – Express app setup & entry point
• package.json + .env.example – dependencies & env-config
• Folders:
• routes/ – HTTP route definitions (e.g., userRoutes.js)
• controllers/ – Business logic handlers (e.g., userController.js)
• ai/ – Core AI logic (autoDocAgent.js) that calls Google Gemini
• docs/ – The Markdown file being maintained
• CI/CD & automation: npm scripts in package.json to run generate-docs
README
• Confirms: Express + File System + Google Gemini + Git integration
• Usage pattern: run npm start for server; run npm run generate-docs for docs update
• Emphasizes integration points: Git CLI, Generative AI API, file writes, optional Git commit
a. Main components
1. CLI / Scheduler / CI Pipeline
2. Express Application (app.js)
– Routes layer (routes/userRoutes.js)
– Controllers layer (controllers/userController.js)
3. AI Agent Module (ai/autoDocAgent.js)
4. Git Subsystem (executes git diff, git commit)
5. File System (docs/UPDATED_DOCUMENTATION.md)
6. Google Gemini API (external service)
7. dotenv / Config store (environment variables)
b. Relationships & data flow
• The CLI or CI triggers the “Generate Docs” command →
• Express app (or direct script) loads .env →
• Calls Git Subsystem: fetch diff →
• Passes diff + existing docs to AI Agent →
• AI Agent issues API call to Google Gemini →
• Receives updated Markdown →
• Writes update to docs/UPDATED_DOCUMENTATION.md →
• Optionally invokes Git Subsystem again to commit & push
c. Architectural patterns & design principles
• MVC-style separation: Routes → Controllers
• Single-responsibility modules: AI logic isolated in ai/autoDocAgent.js
• Externalized configuration (dotenv) for API keys & flags
• Scriptable entry points (npm scripts) for integration into CI/CD
d. Key technologies & libraries
• Express.js (HTTP server)
• Node.js File System (fs)
• child_process or simple-git for Git operations
• Google Gemini 2.5 via Generative AI API
• dotenv for config