# vijaykumar-devcode/llm-question-answering-chatbot architecture

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

- Interactive diagram: https://gitdiagram.com/vijaykumar-devcode/llm-question-answering-chatbot
- Repository: https://github.com/vijaykumar-devcode/llm-question-answering-chatbot

## Overview

DocuMind is a Streamlit document-QA app. Users upload PDFs, process them into a locally persisted FAISS index, then ask questions; retrieval supplies document context and conversation history to Gemini, and the UI shows answers with citations. The graph separates ingestion, indexing, retrieval, and answer generation, with utilities as an internal support layer. The README documents the overall pipeline; source excerpts confirm key calls and implementations. Some components are distinct responsibilities within the same module, not separate files.

Main entry points: [`chatbot.py`](https://github.com/vijaykumar-devcode/llm-question-answering-chatbot/blob/main/chatbot.py) (RAG orchestration), [`app.py`](https://github.com/vijaykumar-devcode/llm-question-answering-chatbot/blob/main/app.py) (Streamlit app), [`vector_store.py`](https://github.com/vijaykumar-devcode/llm-question-answering-chatbot/blob/main/vector_store.py) (FAISS index), [`pdf_loader.py`](https://github.com/vijaykumar-devcode/llm-question-answering-chatbot/blob/main/pdf_loader.py) (PDF extraction)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_interface["User interface"]
  node_streamlit["Streamlit app<br/>[app.py]"]
  node_session["Chat session<br/>[app.py]"]
end

subgraph group_ingestion["Document ingestion"]
  node_upload["PDF upload<br/>[app.py]"]
  node_pdf_processing["PDF extraction<br/>[pdf_loader.py]"]
  node_file_storage[("Uploaded files<br/>[utils.py]")]
end

subgraph group_indexing["Indexing and retrieval"]
  node_chunking["Text chunking<br/>[vector_store.py]"]
  node_embeddings["HuggingFace embeddings<br/>[vector_store.py]"]
  node_faiss[("FAISS index<br/>[vector_store.py]")]
  node_persistence[("Index persistence<br/>[vector_store.py]")]
  node_retrieval["Similarity retrieval<br/>[vector_store.py]"]
end

subgraph group_answering["Grounded answering"]
  node_rag["RAG orchestration<br/>[chatbot.py]"]
  node_prompt["Grounding prompt<br/>[prompt.py]"]
  node_gemini["Google Gemini"]
  node_citations["Source citations<br/>[chatbot.py]"]
end

subgraph group_support["Application support"]
  node_utilities["Environment and validation<br/>[utils.py]"]
end

node_user(("User"))

node_user -->|"selects PDFs"| node_upload
node_user -->|"asks questions"| node_session
node_upload -->|"submits files"| node_streamlit
node_streamlit -->|"loads PDFs"| node_pdf_processing
node_pdf_processing -->|"saves uploads"| node_file_storage
node_pdf_processing -->|"passes pages"| node_chunking
node_streamlit -->|"builds index"| node_faiss
node_chunking -->|"creates vectors"| node_embeddings
node_embeddings -->|"indexes vectors"| node_faiss
node_faiss -->|"saves locally"| node_persistence
node_persistence -->|"loads index"| node_faiss
node_streamlit -->|"loads saved index"| node_persistence
node_session -->|"invokes question"| node_rag
node_rag -->|"retrieves chunks"| node_retrieval
node_retrieval -->|"searches index"| node_faiss
node_rag -->|"formats prompt"| node_prompt
node_rag -->|"generates answer"| node_gemini
node_rag -->|"extracts references"| node_citations
node_citations -->|"renders citations"| node_streamlit
node_rag -->|"returns answer"| node_session
node_pdf_processing -->|"validates and saves"| node_utilities
node_streamlit -->|"checks configuration"| node_utilities
node_rag -->|"gets API key"| node_utilities

click node_streamlit "https://github.com/vijaykumar-devcode/llm-question-answering-chatbot/blob/main/app.py"
click node_session "https://github.com/vijaykumar-devcode/llm-question-answering-chatbot/blob/main/app.py"
click node_upload "https://github.com/vijaykumar-devcode/llm-question-answering-chatbot/blob/main/app.py"
click node_pdf_processing "https://github.com/vijaykumar-devcode/llm-question-answering-chatbot/blob/main/pdf_loader.py"
click node_file_storage "https://github.com/vijaykumar-devcode/llm-question-answering-chatbot/blob/main/utils.py"
click node_chunking "https://github.com/vijaykumar-devcode/llm-question-answering-chatbot/blob/main/vector_store.py"
click node_embeddings "https://github.com/vijaykumar-devcode/llm-question-answering-chatbot/blob/main/vector_store.py"
click node_faiss "https://github.com/vijaykumar-devcode/llm-question-answering-chatbot/blob/main/vector_store.py"
click node_persistence "https://github.com/vijaykumar-devcode/llm-question-answering-chatbot/blob/main/vector_store.py"
click node_retrieval "https://github.com/vijaykumar-devcode/llm-question-answering-chatbot/blob/main/vector_store.py"
click node_rag "https://github.com/vijaykumar-devcode/llm-question-answering-chatbot/blob/main/chatbot.py"
click node_prompt "https://github.com/vijaykumar-devcode/llm-question-answering-chatbot/blob/main/prompt.py"
click node_citations "https://github.com/vijaykumar-devcode/llm-question-answering-chatbot/blob/main/chatbot.py"
click node_utilities "https://github.com/vijaykumar-devcode/llm-question-answering-chatbot/blob/main/utils.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_session,node_user toneBlue
class node_upload,node_pdf_processing,node_file_storage toneAmber
class node_chunking,node_embeddings,node_faiss,node_persistence,node_retrieval toneMint
class node_rag,node_prompt,node_gemini,node_citations toneRose
class node_utilities toneIndigo
```

## Components

### User interface

- [Streamlit app](https://github.com/vijaykumar-devcode/llm-question-answering-chatbot/blob/main/app.py): `app.py`
- [Chat session](https://github.com/vijaykumar-devcode/llm-question-answering-chatbot/blob/main/app.py): `app.py`

### Document ingestion

- [PDF upload](https://github.com/vijaykumar-devcode/llm-question-answering-chatbot/blob/main/app.py): `app.py`
- [PDF extraction](https://github.com/vijaykumar-devcode/llm-question-answering-chatbot/blob/main/pdf_loader.py): `pdf_loader.py`
- [Uploaded files](https://github.com/vijaykumar-devcode/llm-question-answering-chatbot/blob/main/utils.py): `utils.py`

### Indexing and retrieval

- [Text chunking](https://github.com/vijaykumar-devcode/llm-question-answering-chatbot/blob/main/vector_store.py): `vector_store.py`
- [HuggingFace embeddings](https://github.com/vijaykumar-devcode/llm-question-answering-chatbot/blob/main/vector_store.py): `vector_store.py`
- [FAISS index](https://github.com/vijaykumar-devcode/llm-question-answering-chatbot/blob/main/vector_store.py): `vector_store.py`
- [Index persistence](https://github.com/vijaykumar-devcode/llm-question-answering-chatbot/blob/main/vector_store.py): `vector_store.py`
- [Similarity retrieval](https://github.com/vijaykumar-devcode/llm-question-answering-chatbot/blob/main/vector_store.py): `vector_store.py`

### Grounded answering

- [RAG orchestration](https://github.com/vijaykumar-devcode/llm-question-answering-chatbot/blob/main/chatbot.py): `chatbot.py`
- [Grounding prompt](https://github.com/vijaykumar-devcode/llm-question-answering-chatbot/blob/main/prompt.py): `prompt.py`
- **Google Gemini**
- [Source citations](https://github.com/vijaykumar-devcode/llm-question-answering-chatbot/blob/main/chatbot.py): `chatbot.py`

### Application support

- [Environment and validation](https://github.com/vijaykumar-devcode/llm-question-answering-chatbot/blob/main/utils.py): `utils.py`

### Other components

- **User**

## Connections

- User → PDF upload: selects PDFs (evidence: `README.md`)
- User → Chat session: asks questions (evidence: `README.md`)
- PDF upload → Streamlit app: submits files (evidence: `app.py`)
- Streamlit app → PDF extraction: loads PDFs (evidence: `app.py`)
- PDF extraction → Uploaded files: saves uploads (evidence: `pdf_loader.py`)
- PDF extraction → Text chunking: passes pages (evidence: `README.md`)
- Streamlit app → FAISS index: builds index (evidence: `app.py`)
- Text chunking → HuggingFace embeddings: creates vectors (evidence: `README.md`)
- HuggingFace embeddings → FAISS index: indexes vectors (evidence: `README.md`)
- FAISS index → Index persistence: saves locally (evidence: `vector_store.py`)
- Index persistence → FAISS index: loads index (evidence: `vector_store.py`)
- Streamlit app → Index persistence: loads saved index (evidence: `app.py`)
- Chat session → RAG orchestration: invokes question (evidence: `app.py`)
- RAG orchestration → Similarity retrieval: retrieves chunks (evidence: `chatbot.py`)
- Similarity retrieval → FAISS index: searches index (evidence: `README.md`)
- RAG orchestration → Grounding prompt: formats prompt (evidence: `chatbot.py`)
- RAG orchestration → Google Gemini: generates answer (evidence: `README.md`)
- RAG orchestration → Source citations: extracts references (evidence: `chatbot.py`)
- Source citations → Streamlit app: renders citations (evidence: `app.py`)
- RAG orchestration → Chat session: returns answer (evidence: `app.py`)
- PDF extraction → Environment and validation: validates and saves (evidence: `pdf_loader.py`)
- Streamlit app → Environment and validation: checks configuration (evidence: `app.py`)
- RAG orchestration → Environment and validation: gets API key (evidence: `chatbot.py`)
