How manvadariya/askyourdocuments works
1. Overall shape
This repo is a notebook-centered document Q&A app. The main application logic appears to live in AskYourDocuments.ipynb, while the templates/ and static/ folders provide a lightweight web UI around it.
2. Primary runtime entrypoint
AskYourDocuments.ipynb is the central orchestration layer. The README says it can initialize the backend, run the app, and optionally auto-start Flask unless AUTO_START_FLASK=0 is set. That makes the notebook both the development workflow and the application bootstrap.
3. Bootstrap and execution wrapper
scripts/run_notebook.sh is the operational entrypoint for local/CI execution. It creates a virtual environment, installs requirements.txt, and runs the notebook in a non-blocking mode for validation. This script is the repo’s repeatable setup boundary.
4. Backend responsibility
The backend is Python-based and likely embedded in the notebook rather than split into a separate package. Its role is to accept documents, process them, call LLM/embedding services, and serve responses to the web layer. The repo does not show a conventional app/ or src/ layout, so the notebook is the main application container.
5. Document ingestion and processing path
The app is designed to accept PDFs, DOCX, XLSX, PPTX, and images. The processing pipeline likely converts those inputs into text or OCR-derived content, then prepares them for downstream analysis. This is the core “document intelligence” boundary in the system.
6. Retrieval and chat flow
The architecture is consistent with a retrieval-augmented chat system: user asks a question in the UI, the backend uses document-derived context to answer, and the response is returned conversationally. The README explicitly mentions both “chat” and “embeddings,” so there is likely a chunking/indexing step before query-time retrieval.
7. External model services
The system depends on external AI providers rather than local models. GITHUB_TOKEN is used for GitHub Models API access for both chat and embeddings, and HF_TOKEN is used for Hugging Face vision/OCR model access. AZURE_LLM_MODEL_NAME and HF_VISION_MODEL_ID are configuration points, not separate subsystems.
8. Vision/OCR branch
Images are a first-class input type, so there is a separate vision/OCR path in addition to text document parsing. That path likely feeds extracted text or structured observations into the same retrieval/chat pipeline as PDFs and office documents.
9. Web presentation layer
The browser-facing UI is built from Jinja-style templates in templates/chat.html and templates/hero-geometric.html. This suggests a server-rendered Flask UI rather than a SPA. The templates define the main screens: the chat experience and a landing/hero page.
10. Client-side interaction
static/js/chat.js and static/js/documents.js provide browser-side behavior for chat interactions and document handling. These scripts likely manage upload flow, send user messages to backend endpoints, render responses, and update document state without full page reloads.
11. Deployment and access
NGROK_AUTHTOKEN is an optional integration for exposing the local app publicly. That indicates the repo is built for local notebook execution first, with tunnel-based sharing as an auxiliary deployment path rather than a dedicated production deployment stack.
12. Key architectural boundary for diagrams
The most important diagram boundary is: browser UI → Flask/notebook backend → document parsing + embedding/retrieval + LLM/OCR services → response back to UI. The notebook and shell script are the execution/control plane, while templates and static JS form the presentation layer.
Main entry points: AskYourDocuments.ipynb Notebook app · chat.html Chat page · documents.js Docs client · chat.js Chat client
Components 16
Runtime & bootstrap
Notebook-driven application entry and repeatable local execution.
- Notebook app · Central application container and primary bootstrap for the document Q&A system.
AskYourDocuments.ipynb - Run script · Repeatable local/CI wrapper that creates the environment and runs the notebook.
scripts/run_notebook.sh
Web UI
Server-rendered pages and browser-side interactions.
- Chat page · Main server-rendered chat interface.
templates/chat.html - Hero page · Landing or introduction screen for the app.
templates/hero-geometric.html - Chat client · Client-side chat behavior and message rendering.
static/js/chat.js - Docs client · Client-side document upload and state handling.
static/js/documents.js
Document Q&A core
Document ingestion, retrieval, and answer generation flow.
- Document flow · Accepts PDFs, DOCX, XLSX, PPTX, and images and turns them into usable content.
- Text parse · Extracts text and structured content from office and PDF documents.
- Vision OCR · Processes images through vision or OCR models before retrieval.
- Chunk index · Splits document content and prepares it for retrieval.
- Retriever · Selects relevant document context for a user question.
- Answer engine · Combines retrieved context with chat prompting to generate answers.
External services
Model and tunnel integrations configured through environment variables.
- GitHub Models · External provider for chat and embedding calls via token-based access.
- Hugging Face · External provider for vision and OCR model access.
- Azure model name · Model selection setting used by the notebook backend.
- Ngrok · Optional public exposure path for a locally running app.
Connections 18
- Run script → Notebook app: executes · Runs the notebook in a repeatable environment.
- Notebook app → Chat page: renders · Serves the chat UI through the backend.
- Notebook app → Hero page: renders · Serves the landing page template.
- Chat page → Chat client: uses · Chat page behavior is driven by the browser script.
- Chat page → Docs client: uses · Document interactions are driven by the browser script.
- Docs client → Document flow: uploads · Client-side document handling feeds the ingestion flow.
- Document flow → Text parse: extracts · Text documents are parsed into usable content.
- Document flow → Vision OCR: ocr path · Image inputs take the vision/OCR branch.
- Text parse → Chunk index: indexes · Parsed text is chunked and prepared for retrieval.
- Vision OCR → Chunk index: indexes · OCR output is also prepared for retrieval.
- Chunk index → Retriever: retrieves · Indexed content is queried at question time.
- Retriever → Answer engine: supplies context · Retrieved passages feed the answer generator.
- Answer engine → GitHub Models: calls · LLM and embedding requests go to GitHub Models.
- Vision OCR → Hugging Face: calls · Vision and OCR processing uses Hugging Face models.
- Notebook app → Azure model name: configures · Notebook selects the configured LLM model name.
- Notebook app → Ngrok: optional share · Local app can be exposed through an ngrok tunnel.
- Chat client → Notebook app: requests · Chat UI sends questions to the backend endpoints.
- Docs client → Notebook app: requests · Document UI sends upload and management actions to the backend.