# revanthk1001-jpg/ragbot-2 architecture

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

- Interactive diagram: https://gitdiagram.com/revanthk1001-jpg/ragbot-2
- Repository: https://github.com/revanthk1001-jpg/ragbot-2

## Overview

The product is a PDF-grounded RAG chatbot: users upload documents, then ask questions and receive answers with source references; optional evaluation scores responses. The graph separates the Streamlit interface, FastAPI workflows, document/index handling, and model/quality services. Both standard and streaming query paths are shown. The README documents capabilities such as local Hugging Face models and Langfuse tracing; source-level links are included where the excerpts show them.

Main entry points: [`streamlit_app.py`](https://github.com/revanthk1001-jpg/ragbot-2/blob/main/streamlit_app.py) (Streamlit chat), [`main.py`](https://github.com/revanthk1001-jpg/ragbot-2/blob/main/main.py) (Query endpoint), [`faiss-index`](https://github.com/revanthk1001-jpg/ragbot-2/tree/main/faiss-index) (FAISS index)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_ui["Chat interface"]
  node_ui["Streamlit chat<br/>[streamlit_app.py]"]
end

subgraph group_api["API workflows"]
  node_api["FastAPI application<br/>[main.py]"]
  node_ingest_route["Ingest endpoint<br/>[main.py]"]
  node_query_route["Query endpoint<br/>[main.py]"]
  node_stream_route["Streaming endpoint<br/>[main.py]"]
  node_eval_route["Evaluation status<br/>[main.py]"]
  node_prompt["Context prompt<br/>[main.py]"]
  node_eval_results[("Evaluation results<br/>[main.py]")]
end

subgraph group_knowledge["Document knowledge"]
  node_pdf["PDF loading<br/>[main.py]"]
  node_chunking["Text splitting<br/>[main.py]"]
  node_faiss[("FAISS index")]
  node_retrieval["Semantic retrieval<br/>[main.py]"]
end

subgraph group_models["Models and quality"]
  node_embedding["Embedding model<br/>[main.py]"]
  node_generation["LLM generation<br/>[main.py]"]
  node_eval_job["Background evaluation<br/>[main.py]"]
end

node_user(("Chat user"))
node_hf_models["Hugging Face models"]
node_langfuse["Langfuse tracing"]
node_deepeval["DeepEval metrics"]

node_user -->|"uses"| node_ui
node_ui -->|"uploads PDF"| node_ingest_route
node_ui -->|"streams query"| node_stream_route
node_ui -->|"requests evaluation"| node_query_route
node_ui -->|"fetches scores"| node_eval_route
node_ingest_route -->|"loads PDF"| node_pdf
node_pdf -->|"splits pages"| node_chunking
node_chunking -->|"embeds chunks"| node_embedding
node_chunking -->|"builds and saves"| node_faiss
node_embedding -->|"indexes vectors"| node_faiss
node_query_route -->|"retrieves context"| node_retrieval
node_stream_route -->|"retrieves context"| node_retrieval
node_retrieval -->|"searches index"| node_faiss
node_query_route -->|"builds prompt"| node_prompt
node_stream_route -->|"builds prompt"| node_prompt
node_prompt -->|"supplies prompt"| node_generation
node_generation -->|"runs local model"| node_hf_models
node_generation -->|"traces generation"| node_langfuse
node_query_route -->|"schedules evaluation"| node_eval_job
node_eval_job -->|"measures responses"| node_deepeval
node_eval_job -->|"stores scores"| node_eval_results
node_eval_route -->|"reads scores"| node_eval_results

click node_ui "https://github.com/revanthk1001-jpg/ragbot-2/blob/main/streamlit_app.py"
click node_api "https://github.com/revanthk1001-jpg/ragbot-2/blob/main/main.py"
click node_ingest_route "https://github.com/revanthk1001-jpg/ragbot-2/blob/main/main.py"
click node_query_route "https://github.com/revanthk1001-jpg/ragbot-2/blob/main/main.py"
click node_stream_route "https://github.com/revanthk1001-jpg/ragbot-2/blob/main/main.py"
click node_eval_route "https://github.com/revanthk1001-jpg/ragbot-2/blob/main/main.py"
click node_pdf "https://github.com/revanthk1001-jpg/ragbot-2/blob/main/main.py"
click node_chunking "https://github.com/revanthk1001-jpg/ragbot-2/blob/main/main.py"
click node_embedding "https://github.com/revanthk1001-jpg/ragbot-2/blob/main/main.py"
click node_faiss "https://github.com/revanthk1001-jpg/ragbot-2/tree/main/faiss-index"
click node_retrieval "https://github.com/revanthk1001-jpg/ragbot-2/blob/main/main.py"
click node_prompt "https://github.com/revanthk1001-jpg/ragbot-2/blob/main/main.py"
click node_generation "https://github.com/revanthk1001-jpg/ragbot-2/blob/main/main.py"
click node_eval_job "https://github.com/revanthk1001-jpg/ragbot-2/blob/main/main.py"
click node_eval_results "https://github.com/revanthk1001-jpg/ragbot-2/blob/main/main.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_ui,node_user toneBlue
class node_api,node_ingest_route,node_query_route,node_stream_route,node_eval_route,node_prompt,node_eval_results toneAmber
class node_pdf,node_chunking,node_faiss,node_retrieval toneMint
class node_embedding,node_generation,node_eval_job toneRose
class node_hf_models,node_langfuse,node_deepeval toneIndigo
```

## Components

### Chat interface

- [Streamlit chat](https://github.com/revanthk1001-jpg/ragbot-2/blob/main/streamlit_app.py): `streamlit_app.py`

### API workflows

- [FastAPI application](https://github.com/revanthk1001-jpg/ragbot-2/blob/main/main.py): `main.py`
- [Ingest endpoint](https://github.com/revanthk1001-jpg/ragbot-2/blob/main/main.py): `main.py`
- [Query endpoint](https://github.com/revanthk1001-jpg/ragbot-2/blob/main/main.py): `main.py`
- [Streaming endpoint](https://github.com/revanthk1001-jpg/ragbot-2/blob/main/main.py): `main.py`
- [Evaluation status](https://github.com/revanthk1001-jpg/ragbot-2/blob/main/main.py): `main.py`
- [Context prompt](https://github.com/revanthk1001-jpg/ragbot-2/blob/main/main.py): `main.py`
- [Evaluation results](https://github.com/revanthk1001-jpg/ragbot-2/blob/main/main.py): `main.py`

### Document knowledge

- [PDF loading](https://github.com/revanthk1001-jpg/ragbot-2/blob/main/main.py): `main.py`
- [Text splitting](https://github.com/revanthk1001-jpg/ragbot-2/blob/main/main.py): `main.py`
- [FAISS index](https://github.com/revanthk1001-jpg/ragbot-2/tree/main/faiss-index): `faiss-index`
- [Semantic retrieval](https://github.com/revanthk1001-jpg/ragbot-2/blob/main/main.py): `main.py`

### Models and quality

- [Embedding model](https://github.com/revanthk1001-jpg/ragbot-2/blob/main/main.py): `main.py`
- [LLM generation](https://github.com/revanthk1001-jpg/ragbot-2/blob/main/main.py): `main.py`
- [Background evaluation](https://github.com/revanthk1001-jpg/ragbot-2/blob/main/main.py): `main.py`

### Other components

- **Chat user**
- **Hugging Face models**
- **Langfuse tracing**
- **DeepEval metrics**

## Connections

- Chat user → Streamlit chat: uses (evidence: `README.md`)
- Streamlit chat → Ingest endpoint: uploads PDF (evidence: `streamlit_app.py`)
- Streamlit chat → Streaming endpoint: streams query (evidence: `streamlit_app.py`)
- Streamlit chat → Query endpoint: requests evaluation (evidence: `streamlit_app.py`)
- Streamlit chat → Evaluation status: fetches scores (evidence: `streamlit_app.py`)
- Ingest endpoint → PDF loading: loads PDF (evidence: `main.py`)
- PDF loading → Text splitting: splits pages (evidence: `main.py`)
- Text splitting → Embedding model: embeds chunks (evidence: `main.py`)
- Text splitting → FAISS index: builds and saves (evidence: `main.py`)
- Embedding model → FAISS index: indexes vectors (evidence: `main.py`)
- Query endpoint → Semantic retrieval: retrieves context (evidence: `main.py`)
- Streaming endpoint → Semantic retrieval: retrieves context (evidence: `main.py`)
- Semantic retrieval → FAISS index: searches index (evidence: `main.py`)
- Query endpoint → Context prompt: builds prompt (evidence: `main.py`)
- Streaming endpoint → Context prompt: builds prompt (evidence: `main.py`)
- Context prompt → LLM generation: supplies prompt (evidence: `main.py`)
- LLM generation → Hugging Face models: runs local model (evidence: `README.md`)
- LLM generation → Langfuse tracing: traces generation (evidence: `main.py`)
- Query endpoint → Background evaluation: schedules evaluation (evidence: `main.py`)
- Background evaluation → DeepEval metrics: measures responses (evidence: `main.py`)
- Background evaluation → Evaluation results: stores scores (evidence: `main.py`)
- Evaluation status → Evaluation results: reads scores (evidence: `main.py`)
