# nilesh07g/askmydocs architecture

> Architecture diagram of the GitHub repository nilesh07g/askmydocs, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-09). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/nilesh07g/askmydocs
- Repository: https://github.com/nilesh07g/askmydocs

## Overview

AskMyDocs is a Streamlit PDF question-answering app. A user uploads a PDF, which is extracted into page-tagged chunks and indexed; questions are routed, retrieved with hybrid search, reranked, and answered with page citations. The UI also streams responses and displays retrieved sources. The graph captures the documented caching and LangSmith tracing capabilities. Evaluation is a separate harness, not part of the runtime product map. Relationships involving unsampled app sections rely on the SOURCE INDEX or README; uncertain links are omitted.

Main entry points: [`app.py`](https://github.com/nilesh07g/askmydocs/blob/main/app.py) (Streamlit chat), [`rag/router.py`](https://github.com/nilesh07g/askmydocs/blob/main/rag/router.py) (Intent and query routing), [`rag/answer.py`](https://github.com/nilesh07g/askmydocs/blob/main/rag/answer.py) (Grounded answer generation), [`rag/config.py`](https://github.com/nilesh07g/askmydocs/blob/main/rag/config.py) (Pipeline settings)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_ui["User interface"]
  node_app["Streamlit chat<br/>[app.py]"]
end

subgraph group_document["Document preparation"]
  node_ingest["PDF extraction and chunking<br/>[ingest.py]"]
  node_embed["Embedding and FAISS index<br/>[embed.py]"]
  node_cache[("Embedding cache<br/>[cache.py]")]
  node_config["Pipeline settings<br/>[config.py]"]
end

subgraph group_retrieval["Question retrieval"]
  node_router["Intent and query routing<br/>[router.py]"]
  node_hybrid["BM25 and vector fusion<br/>[hybrid.py]"]
  node_retrieve["Vector search<br/>[retrieve.py]"]
  node_rerank["Cross-encoder reranking<br/>[rerank.py]"]
end

subgraph group_answer["Answer generation"]
  node_answer["Grounded answer generation<br/>[answer.py]"]
  node_prompts["Router and answer prompts<br/>[prompts.py]"]
end

node_user(("PDF user"))
node_groq{{"Groq API"}}
node_gemini{{"Gemini API"}}
node_langsmith{{"LangSmith tracing"}}

node_user -->|"uploads and asks"| node_app
node_app -->|"extracts and chunks"| node_ingest
node_app -->|"builds index"| node_embed
node_app -->|"loads or saves"| node_cache
node_app -->|"routes query"| node_router
node_app -->|"retrieves candidates"| node_hybrid
node_app -->|"reranks candidates"| node_rerank
node_app -->|"streams answer"| node_answer
node_router -->|"classifies intent"| node_groq
node_router -->|"uses router prompt"| node_prompts
node_hybrid -->|"runs vector search"| node_retrieve
node_answer -->|"uses answer prompt"| node_prompts
node_answer -->|"generates response"| node_gemini
node_router -->|"uses model setting"| node_config
node_answer -->|"uses model setting"| node_config
node_ingest -->|"uses chunk settings"| node_config
node_embed -->|"uses model setting"| node_config
node_app -->|"traces pipeline"| node_langsmith

click node_app "https://github.com/nilesh07g/askmydocs/blob/main/app.py"
click node_ingest "https://github.com/nilesh07g/askmydocs/blob/main/rag/ingest.py"
click node_embed "https://github.com/nilesh07g/askmydocs/blob/main/rag/embed.py"
click node_cache "https://github.com/nilesh07g/askmydocs/blob/main/rag/cache.py"
click node_config "https://github.com/nilesh07g/askmydocs/blob/main/rag/config.py"
click node_router "https://github.com/nilesh07g/askmydocs/blob/main/rag/router.py"
click node_hybrid "https://github.com/nilesh07g/askmydocs/blob/main/rag/hybrid.py"
click node_retrieve "https://github.com/nilesh07g/askmydocs/blob/main/rag/retrieve.py"
click node_rerank "https://github.com/nilesh07g/askmydocs/blob/main/rag/rerank.py"
click node_answer "https://github.com/nilesh07g/askmydocs/blob/main/rag/answer.py"
click node_prompts "https://github.com/nilesh07g/askmydocs/blob/main/rag/prompts.py"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_app,node_user toneBlue
class node_ingest,node_embed,node_cache,node_config toneAmber
class node_router,node_hybrid,node_retrieve,node_rerank,node_groq,node_gemini toneMint
class node_answer,node_prompts toneRose
class node_langsmith toneIndigo
```

## Components

### User interface

- [Streamlit chat](https://github.com/nilesh07g/askmydocs/blob/main/app.py): `app.py`

### Document preparation

- [PDF extraction and chunking](https://github.com/nilesh07g/askmydocs/blob/main/rag/ingest.py): `rag/ingest.py`
- [Embedding and FAISS index](https://github.com/nilesh07g/askmydocs/blob/main/rag/embed.py): `rag/embed.py`
- [Embedding cache](https://github.com/nilesh07g/askmydocs/blob/main/rag/cache.py): `rag/cache.py`
- [Pipeline settings](https://github.com/nilesh07g/askmydocs/blob/main/rag/config.py): `rag/config.py`

### Question retrieval

- [Intent and query routing](https://github.com/nilesh07g/askmydocs/blob/main/rag/router.py): `rag/router.py`
- [BM25 and vector fusion](https://github.com/nilesh07g/askmydocs/blob/main/rag/hybrid.py): `rag/hybrid.py`
- [Vector search](https://github.com/nilesh07g/askmydocs/blob/main/rag/retrieve.py): `rag/retrieve.py`
- [Cross-encoder reranking](https://github.com/nilesh07g/askmydocs/blob/main/rag/rerank.py): `rag/rerank.py`

### Answer generation

- [Grounded answer generation](https://github.com/nilesh07g/askmydocs/blob/main/rag/answer.py): `rag/answer.py`
- [Router and answer prompts](https://github.com/nilesh07g/askmydocs/blob/main/rag/prompts.py): `rag/prompts.py`

### Other components

- **PDF user**
- **Groq API**
- **Gemini API**
- **LangSmith tracing**

## Connections

- PDF user → Streamlit chat: uploads and asks (evidence: `README.md`)
- Streamlit chat → PDF extraction and chunking: extracts and chunks (evidence: `app.py`)
- Streamlit chat → Embedding and FAISS index: builds index (evidence: `app.py`)
- Streamlit chat → Embedding cache: loads or saves (evidence: `app.py`)
- Streamlit chat → Intent and query routing: routes query (evidence: `app.py`)
- Streamlit chat → BM25 and vector fusion: retrieves candidates (evidence: `app.py`)
- Streamlit chat → Cross-encoder reranking: reranks candidates (evidence: `app.py`)
- Streamlit chat → Grounded answer generation: streams answer (evidence: `app.py`)
- Intent and query routing → Groq API: classifies intent (evidence: `rag/router.py`)
- Intent and query routing → Router and answer prompts: uses router prompt (evidence: `rag/router.py`)
- BM25 and vector fusion → Vector search: runs vector search (evidence: `rag/hybrid.py`)
- Grounded answer generation → Router and answer prompts: uses answer prompt (evidence: `rag/answer.py`)
- Grounded answer generation → Gemini API: generates response (evidence: `rag/answer.py`)
- Intent and query routing → Pipeline settings: uses model setting (evidence: `rag/router.py`)
- Grounded answer generation → Pipeline settings: uses model setting (evidence: `rag/answer.py`)
- PDF extraction and chunking → Pipeline settings: uses chunk settings (evidence: `rag/ingest.py`)
- Embedding and FAISS index → Pipeline settings: uses model setting (evidence: `rag/embed.py`)
- Streamlit chat → LangSmith tracing: traces pipeline (evidence: `README.md`)
