How mahender-reddy85/docuquery works
Project type & purpose (what you’re diagramming)
DocuQuery is a small full-stack web application with a privacy-first architecture:
• Frontend (static HTML/CSS/vanilla JS) runs in the browser and does:
• File upload (PDF/DOCX/TXT)
• Client-side text extraction (PDF.js, Mammoth.js, TXT parsing)
• Chat UI + session state (chat history, theme preference)
• Calls backend only to generate AI responses
• Backend (Node/Express proxy) exists primarily to:
• Hide the Gemini API key in server-side env (GEMINI_API_KEY)
• Forward requests to Google Gemini (gemini-2.0-flash) via POST /api/generate
That means the “system” is intentionally simple: Browser does the heavy lifting; server is a thin credentialed proxy.
File tree analysis (map code to components)
Actual repository tree indicates a split app:
Frontend
• frontend/index.html – UI structure: upload screen + Q&A screen
• frontend/DocuQuery.js – main client logic:
• drag/drop + file picker
• text extraction pipeline per file type
• prompt construction (document grounding)
• fetch to backend /api/generate
• theme toggle + localStorage
• frontend/DocuQuery.css – responsive + dark mode styling
Backend
• backend/server.js – Express server exposing POST /api/generate
• backend/package.json / lock – backend dependencies/scripts
Top-level
• README.md – explains “client-side processing” + proxy server pattern
This strongly suggests a 2-tier architecture with an external AI dependency.
Client (Browser) — primary compute + data handling
Subcomponents worth drawing separately (because they matter to privacy/flow):
Upload & File Handler
• Drag & drop, file picker
• Accepts PDF/DOCX/TXT (PPTX shown but not implemented)
Text Extraction Layer (in-browser)
• PDF.js → extracted text
• Mammoth.js → extracted text
• TXT → raw text
Document Text Store (in-memory)
• Extracted text kept in browser memory (not persisted server-side)
Chat / Prompt Builder
• Builds “grounded” request using extracted document text + user question
• Maintains chat history for the session
UI & Theme Manager
• Light/dark mode, responsive layout
• localStorage only for theme preference (not documents)
Backend (Node/Express) — security boundary + proxy
Subcomponents to show:
Express API
• POST /api/generate
Environment / Secrets
• GEMINI_API_KEY from .env/env var
Request Forwarder
• Calls Gemini endpoint and returns response
(Implicit) CORS / HTTP boundary
• Browser → localhost:3000
Google Gemini API
• Model: gemini-2.0-flash
• Receives prompt (document text + question) and returns generated answer
User → Browser UI
• Upload document
Browser → Text Extraction
• PDF.js/Mammoth.js parse locally
Browser stores extracted text
• “Document Text (in-memory)”
User → Browser Chat input
• Ask a question
Browser Prompt Builder
• Combines question + extracted text into a grounded request
Browser → Backend
• POST /api/generate (payload includes document text and question, plus settings like temperature if present)
Backend → Gemini API
• Adds API key server-side
• Forwards request
Gemini API → Backend → Browser
• Response returned to UI chat panel
• Document extraction stays in the browser
• No persistent storage (no DB)
• API key never goes to the browser
Thin Backend / Backend-for-Frontend (BFF) Proxy
• Backend exists to protect secrets and normalize API calls
Client-side processing
• Compute-heavy extraction is local
External AI dependency
• Gemini is a runtime dependency; model name is part of architecture
No database / stateless server
• The server can be drawn stateless (horizontal scaling possible)
Trust boundaries
• Browser is untrusted for secrets; backend is trusted for key storage
“Don’t overthink it”: maximize components without inventing things
Given the repo size, the most common diagramming mistake is adding infrastructure that isn’t present (queues, vector DBs, object storage, auth). This project currently has:
• static frontend files
• one Node server
• one external API
So be detailed by splitting real responsibilities (upload, extraction, prompt building, proxying), not by adding imaginary services.