# laaqshya/rag-bot architecture

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

- Interactive diagram: https://gitdiagram.com/laaqshya/rag-bot
- Repository: https://github.com/laaqshya/rag-bot

## Overview

Baahubali RAG Bot is a Streamlit chat application that answers questions from a franchise-specific knowledge base. Its main workflow accepts a user question, optionally asks for a subject and answer format, retrieves relevant chunks, generates an answer with Gemini, and saves the exchange. Separate capabilities include document ingestion, conversation history and feedback, and text-to-speech playback. The excerpts show the principal calls and storage behavior; the README is empty, and some UI and integration details are unsampled.

Main entry points: [`RAG-BOT/app.py`](https://github.com/laaqshya/rag-bot/blob/main/RAG-BOT/app.py) (Streamlit app), [`RAG-BOT/services/chroma_service.py`](https://github.com/laaqshya/rag-bot/blob/main/RAG-BOT/services/chroma_service.py) (Vector index service), [`RAG-BOT/ingest.py`](https://github.com/laaqshya/rag-bot/blob/main/RAG-BOT/ingest.py) (Document ingestion), [`RAG-BOT/services/rag_pipeline.py`](https://github.com/laaqshya/rag-bot/blob/main/RAG-BOT/services/rag_pipeline.py) (RAG coordinator)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_chat["Chat experience"]
  node_app["Streamlit app<br/>[app.py]"]
  node_clarification["Query clarification<br/>[app.py]"]
end

subgraph group_knowledge["Knowledge retrieval"]
  node_ingestion["Document ingestion<br/>[ingest.py]"]
  node_source["Baahubali source"]
  node_chunker["Section chunker<br/>[chunker.py]"]
  node_vector_service["Vector index service<br/>[chroma_service.py]"]
  node_vector_db[("Chroma index")]
  node_retriever["Chunk retriever<br/>[retriever.py]"]
end

subgraph group_generation["Answer generation"]
  node_pipeline["RAG coordinator<br/>[rag_pipeline.py]"]
  node_gemini_client["Gemini client<br/>[gemini_client.py]"]
  node_gemini["Google Gemini"]
end

subgraph group_support["Persistence and audio"]
  node_database_service["Chat database service<br/>[database.py]"]
  node_chat_db[("SQLite chat history<br/>[chat_history.db]")]
  node_tts["Speech synthesis<br/>[tts_service.py]"]
  node_gtts["gTTS service"]
  node_audio_cache[("Audio cache")]
end

node_user(("User"))

node_user -->|"asks question"| node_app
node_app -->|"clarifies broad queries"| node_clarification
node_app -->|"starts ingestion"| node_ingestion
node_ingestion -->|"loads text"| node_source
node_ingestion -->|"chunks document"| node_chunker
node_chunker -->|"provides chunks"| node_vector_service
node_vector_service -->|"upserts chunks"| node_vector_db
node_app -->|"submits query"| node_pipeline
node_pipeline -->|"retrieves context"| node_retriever
node_retriever -->|"queries index"| node_vector_service
node_vector_service -->|"searches chunks"| node_vector_db
node_pipeline -->|"generates answer"| node_gemini_client
node_gemini_client -->|"calls model"| node_gemini
node_app -->|"loads and saves chats"| node_database_service
node_database_service -->|"reads and writes"| node_chat_db
node_app -->|"requests audio"| node_tts
node_tts -->|"synthesizes speech"| node_gtts
node_tts -->|"caches MP3"| node_audio_cache

click node_app "https://github.com/laaqshya/rag-bot/blob/main/RAG-BOT/app.py"
click node_clarification "https://github.com/laaqshya/rag-bot/blob/main/RAG-BOT/app.py"
click node_ingestion "https://github.com/laaqshya/rag-bot/blob/main/RAG-BOT/ingest.py"
click node_source "https://github.com/laaqshya/rag-bot/blob/main/RAG-BOT/data/baahubali_source.txt"
click node_chunker "https://github.com/laaqshya/rag-bot/blob/main/RAG-BOT/services/chunker.py"
click node_vector_service "https://github.com/laaqshya/rag-bot/blob/main/RAG-BOT/services/chroma_service.py"
click node_vector_db "https://github.com/laaqshya/rag-bot/tree/main/RAG-BOT/chroma_db"
click node_retriever "https://github.com/laaqshya/rag-bot/blob/main/RAG-BOT/services/retriever.py"
click node_pipeline "https://github.com/laaqshya/rag-bot/blob/main/RAG-BOT/services/rag_pipeline.py"
click node_gemini_client "https://github.com/laaqshya/rag-bot/blob/main/RAG-BOT/services/gemini_client.py"
click node_database_service "https://github.com/laaqshya/rag-bot/blob/main/RAG-BOT/services/database.py"
click node_chat_db "https://github.com/laaqshya/rag-bot/blob/main/RAG-BOT/database/chat_history.db"
click node_tts "https://github.com/laaqshya/rag-bot/blob/main/RAG-BOT/services/tts_service.py"
click node_audio_cache "https://github.com/laaqshya/rag-bot/tree/main/RAG-BOT/audio_cache"

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_clarification,node_user toneBlue
class node_ingestion,node_source,node_chunker,node_vector_service,node_vector_db,node_retriever toneAmber
class node_pipeline,node_gemini_client,node_gemini toneMint
class node_database_service,node_chat_db,node_tts,node_gtts,node_audio_cache toneRose
```

## Components

### Chat experience

- [Streamlit app](https://github.com/laaqshya/rag-bot/blob/main/RAG-BOT/app.py): `RAG-BOT/app.py`
- [Query clarification](https://github.com/laaqshya/rag-bot/blob/main/RAG-BOT/app.py): `RAG-BOT/app.py`

### Knowledge retrieval

- [Document ingestion](https://github.com/laaqshya/rag-bot/blob/main/RAG-BOT/ingest.py): `RAG-BOT/ingest.py`
- [Baahubali source](https://github.com/laaqshya/rag-bot/blob/main/RAG-BOT/data/baahubali_source.txt): `RAG-BOT/data/baahubali_source.txt`
- [Section chunker](https://github.com/laaqshya/rag-bot/blob/main/RAG-BOT/services/chunker.py): `RAG-BOT/services/chunker.py`
- [Vector index service](https://github.com/laaqshya/rag-bot/blob/main/RAG-BOT/services/chroma_service.py): `RAG-BOT/services/chroma_service.py`
- [Chroma index](https://github.com/laaqshya/rag-bot/tree/main/RAG-BOT/chroma_db): `RAG-BOT/chroma_db`
- [Chunk retriever](https://github.com/laaqshya/rag-bot/blob/main/RAG-BOT/services/retriever.py): `RAG-BOT/services/retriever.py`

### Answer generation

- [RAG coordinator](https://github.com/laaqshya/rag-bot/blob/main/RAG-BOT/services/rag_pipeline.py): `RAG-BOT/services/rag_pipeline.py`
- [Gemini client](https://github.com/laaqshya/rag-bot/blob/main/RAG-BOT/services/gemini_client.py): `RAG-BOT/services/gemini_client.py`
- **Google Gemini**

### Persistence and audio

- [Chat database service](https://github.com/laaqshya/rag-bot/blob/main/RAG-BOT/services/database.py): `RAG-BOT/services/database.py`
- [SQLite chat history](https://github.com/laaqshya/rag-bot/blob/main/RAG-BOT/database/chat_history.db): `RAG-BOT/database/chat_history.db`
- [Speech synthesis](https://github.com/laaqshya/rag-bot/blob/main/RAG-BOT/services/tts_service.py): `RAG-BOT/services/tts_service.py`
- **gTTS service**
- [Audio cache](https://github.com/laaqshya/rag-bot/tree/main/RAG-BOT/audio_cache): `RAG-BOT/audio_cache`

### Other components

- **User**

## Connections

- User → Streamlit app: asks question (evidence: `RAG-BOT/app.py`)
- Streamlit app → Query clarification: clarifies broad queries (evidence: `RAG-BOT/app.py`)
- Streamlit app → Document ingestion: starts ingestion (evidence: `RAG-BOT/app.py`)
- Document ingestion → Baahubali source: loads text (evidence: `RAG-BOT/ingest.py`)
- Document ingestion → Section chunker: chunks document (evidence: `RAG-BOT/ingest.py`)
- Section chunker → Vector index service: provides chunks (evidence: `RAG-BOT/ingest.py`)
- Vector index service → Chroma index: upserts chunks (evidence: `RAG-BOT/services/chroma_service.py`)
- Streamlit app → RAG coordinator: submits query (evidence: `RAG-BOT/app.py`)
- RAG coordinator → Chunk retriever: retrieves context (evidence: `RAG-BOT/services/rag_pipeline.py`)
- Chunk retriever → Vector index service: queries index (evidence: `RAG-BOT/services/retriever.py`)
- Vector index service → Chroma index: searches chunks (evidence: `RAG-BOT/services/chroma_service.py`)
- RAG coordinator → Gemini client: generates answer (evidence: `RAG-BOT/services/rag_pipeline.py`)
- Gemini client → Google Gemini: calls model (evidence: `RAG-BOT/services/gemini_client.py`)
- Streamlit app → Chat database service: loads and saves chats (evidence: `RAG-BOT/app.py`)
- Chat database service → SQLite chat history: reads and writes (evidence: `RAG-BOT/services/database.py`)
- Streamlit app → Speech synthesis: requests audio (evidence: `RAG-BOT/app.py`)
- Speech synthesis → gTTS service: synthesizes speech (evidence: `RAG-BOT/services/tts_service.py`)
- Speech synthesis → Audio cache: caches MP3 (evidence: `RAG-BOT/services/tts_service.py`)
