# thatguy4u/docs-bot architecture

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

- Interactive diagram: https://gitdiagram.com/thatguy4u/docs-bot
- Repository: https://github.com/thatguy4u/docs-bot

## Overview

This is a Streamlit PDF question-answering assistant. Users upload PDFs to create a searchable knowledge base, then ask questions; the app retrieves supporting chunks, optionally gates low-confidence results, and generates grounded answers with source excerpts. The graph preserves PDF ingestion, embeddings and local storage, vector and hybrid search, follow-up handling, Gemini generation, and chat presentation. Relationships are limited to calls or flows shown in excerpts or documented by the README; the app excerpt omits some upload and mode-selection logic.

Main entry points: [`app.py`](https://github.com/thatguy4u/docs-bot/blob/main/app.py) (Streamlit chat), [`generator.py`](https://github.com/thatguy4u/docs-bot/blob/main/generator.py) (RAG orchestration), [`embedder.py`](https://github.com/thatguy4u/docs-bot/blob/main/embedder.py) (Embedding and store access), [`retriever.py`](https://github.com/thatguy4u/docs-bot/blob/main/retriever.py) (Vector retrieval and gate)

## Diagram (Mermaid)

```mermaid
flowchart TD

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

subgraph group_ingest["PDF ingestion"]
  node_loader["PDF chunking<br/>[loader.py]"]
end

subgraph group_knowledge["Knowledge and search"]
  node_embedder["Embedding and store access<br/>[embedder.py]"]
  node_chroma[("Local Chroma store")]
  node_retriever["Vector retrieval and gate<br/>[retriever.py]"]
  node_hybrid["BM25 hybrid search<br/>[retriever.py]"]
end

subgraph group_answer["Answer generation"]
  node_generator["RAG orchestration<br/>[generator.py]"]
  node_history["Follow-up condensation<br/>[generator.py]"]
end

node_user(("PDF user"))
node_pdf["Uploaded PDFs"]
node_gemini{{"Gemini model"}}

node_user -->|"uploads and asks"| node_app
node_app -->|"accepts upload"| node_pdf
node_app -.->|"chunks PDF"| node_loader
node_loader -->|"provides chunks"| node_embedder
node_app -.->|"adds documents"| node_embedder
node_embedder -->|"embeds and persists"| node_chroma
node_retriever -->|"loads store"| node_embedder
node_retriever -->|"searches chunks"| node_chroma
node_hybrid -->|"loads store"| node_embedder
node_hybrid -->|"runs vector search"| node_chroma
node_generator -->|"condenses follow-up"| node_history
node_history -->|"rewrites question"| node_gemini
node_generator -->|"retrieves scored chunks"| node_retriever
node_generator -->|"optionally searches"| node_hybrid
node_generator -->|"generates answer"| node_gemini
node_app -->|"requests answer"| node_generator
node_app -->|"renders answer and sources"| node_sources
node_generator -->|"returns chunks and scores"| node_sources

click node_app "https://github.com/thatguy4u/docs-bot/blob/main/app.py"
click node_loader "https://github.com/thatguy4u/docs-bot/blob/main/loader.py"
click node_embedder "https://github.com/thatguy4u/docs-bot/blob/main/embedder.py"
click node_retriever "https://github.com/thatguy4u/docs-bot/blob/main/retriever.py"
click node_hybrid "https://github.com/thatguy4u/docs-bot/blob/main/retriever.py"
click node_generator "https://github.com/thatguy4u/docs-bot/blob/main/generator.py"
click node_history "https://github.com/thatguy4u/docs-bot/blob/main/generator.py"
click node_sources "https://github.com/thatguy4u/docs-bot/blob/main/app.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_sources,node_user toneBlue
class node_loader toneAmber
class node_embedder,node_chroma,node_retriever,node_hybrid toneMint
class node_generator,node_history toneRose
class node_pdf,node_gemini toneIndigo
```

## Components

### User interface

- [Streamlit chat](https://github.com/thatguy4u/docs-bot/blob/main/app.py): `app.py`
- [Answer and citations](https://github.com/thatguy4u/docs-bot/blob/main/app.py): `app.py`

### PDF ingestion

- [PDF chunking](https://github.com/thatguy4u/docs-bot/blob/main/loader.py): `loader.py`

### Knowledge and search

- [Embedding and store access](https://github.com/thatguy4u/docs-bot/blob/main/embedder.py): `embedder.py`
- **Local Chroma store**
- [Vector retrieval and gate](https://github.com/thatguy4u/docs-bot/blob/main/retriever.py): `retriever.py`
- [BM25 hybrid search](https://github.com/thatguy4u/docs-bot/blob/main/retriever.py): `retriever.py`

### Answer generation

- [RAG orchestration](https://github.com/thatguy4u/docs-bot/blob/main/generator.py): `generator.py`
- [Follow-up condensation](https://github.com/thatguy4u/docs-bot/blob/main/generator.py): `generator.py`

### Other components

- **PDF user**
- **Uploaded PDFs**
- **Gemini model**

## Connections

- PDF user → Streamlit chat: uploads and asks (evidence: `README.md`)
- Streamlit chat → Uploaded PDFs: accepts upload (evidence: `README.md`)
- Streamlit chat → PDF chunking: chunks PDF (evidence: `app.py`)
- PDF chunking → Embedding and store access: provides chunks (evidence: `embedder.py`)
- Streamlit chat → Embedding and store access: adds documents (evidence: `app.py`)
- Embedding and store access → Local Chroma store: embeds and persists (evidence: `embedder.py`)
- Vector retrieval and gate → Embedding and store access: loads store (evidence: `retriever.py`)
- Vector retrieval and gate → Local Chroma store: searches chunks (evidence: `retriever.py`)
- BM25 hybrid search → Embedding and store access: loads store (evidence: `retriever.py`)
- BM25 hybrid search → Local Chroma store: runs vector search (evidence: `retriever.py`)
- RAG orchestration → Follow-up condensation: condenses follow-up (evidence: `generator.py`)
- Follow-up condensation → Gemini model: rewrites question (evidence: `generator.py`)
- RAG orchestration → Vector retrieval and gate: retrieves scored chunks (evidence: `generator.py`)
- RAG orchestration → BM25 hybrid search: optionally searches (evidence: `generator.py`)
- RAG orchestration → Gemini model: generates answer (evidence: `generator.py`)
- Streamlit chat → RAG orchestration: requests answer (evidence: `app.py`)
- Streamlit chat → Answer and citations: renders answer and sources (evidence: `app.py`)
- RAG orchestration → Answer and citations: returns chunks and scores (evidence: `generator.py`)
