# vigneshssuvarna/ai-pdf-chatbox architecture

> Architecture diagram of the GitHub repository vigneshssuvarna/ai-pdf-chatbox, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-12-01). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/vigneshssuvarna/ai-pdf-chatbox
- Repository: https://github.com/vigneshssuvarna/ai-pdf-chatbox

## Overview

This repository implements an AI PDF chatbot: users sign in, upload or select documents, ask questions, and receive streamed answers grounded in retrieved document context. The backend also supports document ingestion and web scraping, with separate preprocessing, enrichment, filtering, and indexing modules. The excerpts show API-to-memory, retrieval, and vector-store behavior; several preprocessing modules are indexed but not sampled, so their internal ordering and connections are left unasserted.

Main entry points: [`api_framework.py`](https://github.com/vigneshssuvarna/ai-pdf-chatbox/blob/master/api_framework.py) (Chat API), [`frontend/app.py`](https://github.com/vigneshssuvarna/ai-pdf-chatbox/blob/master/frontend/app.py) (Chat UI), [`frontend/pages/sign_in.py`](https://github.com/vigneshssuvarna/ai-pdf-chatbox/blob/master/frontend/pages/sign_in.py) (Sign-in Page), [`llm.py`](https://github.com/vigneshssuvarna/ai-pdf-chatbox/blob/master/llm.py) (LLM Providers)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_interface["User Interface"]
  node_streamlit["Chat UI<br/>[app.py]"]
  node_authpage["Sign-in Page<br/>[sign_in.py]"]
end

subgraph group_backend["Chat Backend"]
  node_api["Chat API<br/>[api_framework.py]"]
  node_memory["Conversation Memory<br/>[memory.py]"]
  node_prompt["Prompt Builder<br/>[prompting.py]"]
  node_llm["LLM Providers<br/>[llm.py]"]
end

subgraph group_knowledge["Knowledge Preparation"]
  node_ingest["Document Ingestion<br/>[ingest.py]"]
  node_cleaner["Document Cleaning<br/>[data_cleaner.py]"]
  node_chunker["Text Chunking<br/>[data_chunker.py]"]
  node_advanced_chunker["Advanced Chunking"]
  node_ner["NER Enrichment<br/>[enrich_ner.py]"]
  node_audit["Document Audit<br/>[audit.py]"]
  node_filter["Metadata Filtering<br/>[meta_filter.py]"]
end

subgraph group_indexing["Retrieval and Indexing"]
  node_embeddings["Embedding Generation"]
  node_retriever["Semantic Retriever<br/>[retriever.py]"]
  node_vector[("Vector Store<br/>[vector_store.py]")]
end

subgraph group_identity["Authentication"]
  node_authdb[("Account Store<br/>[auth_db.py]")]
end

node_user(("Chat User"))
node_web{{"LLM Services"}}

node_user -->|"asks questions"| node_streamlit
node_streamlit -->|"sends chat"| node_api
node_user -->|"signs in"| node_authpage
node_authpage -->|"checks credentials"| node_authdb
node_api -->|"loads history"| node_memory
node_api -->|"retrieves context"| node_retriever
node_api -->|"builds prompt"| node_prompt
node_api -->|"streams answer"| node_llm
node_llm -->|"requests completion"| node_web
node_api -->|"ingests uploads"| node_ingest
node_api --> node_cleaner
node_api --> node_chunker
node_api -->|"adds chunks"| node_vector
node_retriever -->|"searches chunks"| node_vector

click node_streamlit "https://github.com/vigneshssuvarna/ai-pdf-chatbox/blob/master/frontend/app.py"
click node_authpage "https://github.com/vigneshssuvarna/ai-pdf-chatbox/blob/master/frontend/pages/sign_in.py"
click node_authdb "https://github.com/vigneshssuvarna/ai-pdf-chatbox/blob/master/frontend/auth_db.py"
click node_api "https://github.com/vigneshssuvarna/ai-pdf-chatbox/blob/master/api_framework.py"
click node_memory "https://github.com/vigneshssuvarna/ai-pdf-chatbox/blob/master/memory.py"
click node_prompt "https://github.com/vigneshssuvarna/ai-pdf-chatbox/blob/master/prompting.py"
click node_llm "https://github.com/vigneshssuvarna/ai-pdf-chatbox/blob/master/llm.py"
click node_ingest "https://github.com/vigneshssuvarna/ai-pdf-chatbox/blob/master/ingest.py"
click node_cleaner "https://github.com/vigneshssuvarna/ai-pdf-chatbox/blob/master/data_cleaner.py"
click node_chunker "https://github.com/vigneshssuvarna/ai-pdf-chatbox/blob/master/data_chunker.py"
click node_advanced_chunker "https://github.com/vigneshssuvarna/ai-pdf-chatbox/blob/master/advanced_chunker.py"
click node_ner "https://github.com/vigneshssuvarna/ai-pdf-chatbox/blob/master/enrich_ner.py"
click node_audit "https://github.com/vigneshssuvarna/ai-pdf-chatbox/blob/master/audit.py"
click node_filter "https://github.com/vigneshssuvarna/ai-pdf-chatbox/blob/master/meta_filter.py"
click node_embeddings "https://github.com/vigneshssuvarna/ai-pdf-chatbox/blob/master/generate_embeddings.py"
click node_retriever "https://github.com/vigneshssuvarna/ai-pdf-chatbox/blob/master/retriever.py"
click node_vector "https://github.com/vigneshssuvarna/ai-pdf-chatbox/blob/master/vector_store.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_streamlit,node_authpage,node_user toneBlue
class node_api,node_memory,node_prompt,node_llm toneAmber
class node_ingest,node_cleaner,node_chunker,node_advanced_chunker,node_ner,node_audit,node_filter toneMint
class node_embeddings,node_retriever,node_vector toneRose
class node_authdb,node_web toneIndigo
```

## Components

### User Interface

- [Chat UI](https://github.com/vigneshssuvarna/ai-pdf-chatbox/blob/master/frontend/app.py): `frontend/app.py`
- [Sign-in Page](https://github.com/vigneshssuvarna/ai-pdf-chatbox/blob/master/frontend/pages/sign_in.py): `frontend/pages/sign_in.py`

### Chat Backend

- [Chat API](https://github.com/vigneshssuvarna/ai-pdf-chatbox/blob/master/api_framework.py): `api_framework.py`
- [Conversation Memory](https://github.com/vigneshssuvarna/ai-pdf-chatbox/blob/master/memory.py): `memory.py`
- [Prompt Builder](https://github.com/vigneshssuvarna/ai-pdf-chatbox/blob/master/prompting.py): `prompting.py`
- [LLM Providers](https://github.com/vigneshssuvarna/ai-pdf-chatbox/blob/master/llm.py): `llm.py`

### Knowledge Preparation

- [Document Ingestion](https://github.com/vigneshssuvarna/ai-pdf-chatbox/blob/master/ingest.py): `ingest.py`
- [Document Cleaning](https://github.com/vigneshssuvarna/ai-pdf-chatbox/blob/master/data_cleaner.py): `data_cleaner.py`
- [Text Chunking](https://github.com/vigneshssuvarna/ai-pdf-chatbox/blob/master/data_chunker.py): `data_chunker.py`
- [Advanced Chunking](https://github.com/vigneshssuvarna/ai-pdf-chatbox/blob/master/advanced_chunker.py): `advanced_chunker.py`
- [NER Enrichment](https://github.com/vigneshssuvarna/ai-pdf-chatbox/blob/master/enrich_ner.py): `enrich_ner.py`
- [Document Audit](https://github.com/vigneshssuvarna/ai-pdf-chatbox/blob/master/audit.py): `audit.py`
- [Metadata Filtering](https://github.com/vigneshssuvarna/ai-pdf-chatbox/blob/master/meta_filter.py): `meta_filter.py`

### Retrieval and Indexing

- [Embedding Generation](https://github.com/vigneshssuvarna/ai-pdf-chatbox/blob/master/generate_embeddings.py): `generate_embeddings.py`
- [Semantic Retriever](https://github.com/vigneshssuvarna/ai-pdf-chatbox/blob/master/retriever.py): `retriever.py`
- [Vector Store](https://github.com/vigneshssuvarna/ai-pdf-chatbox/blob/master/vector_store.py): `vector_store.py`

### Authentication

- [Account Store](https://github.com/vigneshssuvarna/ai-pdf-chatbox/blob/master/frontend/auth_db.py): `frontend/auth_db.py`

### Other components

- **Chat User**
- **LLM Services**

## Connections

- Chat User → Chat UI: asks questions (evidence: `frontend/app.py`)
- Chat UI → Chat API: sends chat (evidence: `frontend/app.py`)
- Chat User → Sign-in Page: signs in (evidence: `frontend/pages/sign_in.py`)
- Sign-in Page → Account Store: checks credentials (evidence: `frontend/pages/sign_in.py`)
- Chat API → Conversation Memory: loads history (evidence: `api_framework.py`)
- Chat API → Semantic Retriever: retrieves context (evidence: `api_framework.py`)
- Chat API → Prompt Builder: builds prompt (evidence: `api_framework.py`)
- Chat API → LLM Providers: streams answer (evidence: `api_framework.py`)
- LLM Providers → LLM Services: requests completion (evidence: `llm.py`)
- Chat API → Document Ingestion: ingests uploads (evidence: `api_framework.py`)
- Chat API → Document Cleaning (evidence: `api_framework.py`)
- Chat API → Text Chunking (evidence: `api_framework.py`)
- Chat API → Vector Store: adds chunks (evidence: `api_framework.py`)
- Semantic Retriever → Vector Store: searches chunks (evidence: `retriever.py`)
