# taheryhaia2/chatbot-based-on-rag-architecture architecture

> Architecture diagram of the GitHub repository taheryhaia2/chatbot-based-on-rag-architecture, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-09-26). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/taheryhaia2/chatbot-based-on-rag-architecture
- Repository: https://github.com/taheryhaia2/chatbot-based-on-rag-architecture

## Overview

This is a Streamlit administrative assistant for asking questions about institutional PDFs. Its main workflow is PDF ingestion and indexing, followed by hybrid retrieval and a locally hosted Mistral answer with source context. The app also provides salted-password authentication, session history, and optional speech output. The sampled code is partial and places the application in one file; several capabilities and connections are therefore based on README documentation rather than inspected implementations. gTTS is an optional integration and is not local.

Main entry points: [`chat.py`](https://github.com/taheryhaia2/chatbot-based-on-rag-architecture/blob/master/chat.py) (Streamlit app)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_interface["Chat Interface"]
  node_app["Streamlit app<br/>[chat.py]"]
  node_question["Question handling<br/>[chat.py]"]
  node_sources["Source display<br/>[chat.py]"]
  node_speech["Speech output<br/>[chat.py]"]
end

subgraph group_rag["Document RAG"]
  node_pdf["PDF ingestion<br/>[chat.py]"]
  node_chunking["Semantic chunking<br/>[chat.py]"]
  node_index["Vector indexing<br/>[chat.py]"]
  node_chroma[("Chroma index<br/>[chat.py]")]
  node_hybrid["Hybrid retrieval<br/>[chat.py]"]
  node_prompt["Context prompt<br/>[chat.py]"]
end

subgraph group_identity["Identity And History"]
  node_auth["Authentication<br/>[chat.py]"]
  node_users[("User records<br/>[chat.py]")]
  node_history["Chat history<br/>[chat.py]"]
  node_sessions[("Session records<br/>[chat.py]")]
end

subgraph group_integrations["Runtime Integrations"]
  node_ollama["Ollama models"]
  node_gtts["gTTS service"]
end

node_staff(("Staff user"))

node_staff -->|"uses"| node_app
node_app -->|"authenticates"| node_auth
node_auth -->|"reads / writes"| node_users
node_app -->|"uploads PDF"| node_pdf
node_pdf -->|"extracts text"| node_chunking
node_chunking -->|"creates chunks"| node_index
node_index -->|"embeds with"| node_ollama
node_index -->|"stores vectors"| node_chroma
node_app -->|"submits question"| node_question
node_question -->|"retrieves context"| node_hybrid
node_hybrid -->|"searches vectors"| node_chroma
node_question -->|"formats context"| node_prompt
node_prompt -->|"requests answer"| node_ollama
node_question -->|"provides sources"| node_sources
node_app -->|"manages sessions"| node_history
node_history -->|"reads / writes"| node_sessions
node_app -->|"optionally speaks"| node_speech
node_speech -.->|"generates audio"| node_gtts

click node_app "https://github.com/taheryhaia2/chatbot-based-on-rag-architecture/blob/master/chat.py"
click node_question "https://github.com/taheryhaia2/chatbot-based-on-rag-architecture/blob/master/chat.py"
click node_sources "https://github.com/taheryhaia2/chatbot-based-on-rag-architecture/blob/master/chat.py"
click node_speech "https://github.com/taheryhaia2/chatbot-based-on-rag-architecture/blob/master/chat.py"
click node_pdf "https://github.com/taheryhaia2/chatbot-based-on-rag-architecture/blob/master/chat.py"
click node_chunking "https://github.com/taheryhaia2/chatbot-based-on-rag-architecture/blob/master/chat.py"
click node_index "https://github.com/taheryhaia2/chatbot-based-on-rag-architecture/blob/master/chat.py"
click node_chroma "https://github.com/taheryhaia2/chatbot-based-on-rag-architecture/blob/master/chat.py"
click node_hybrid "https://github.com/taheryhaia2/chatbot-based-on-rag-architecture/blob/master/chat.py"
click node_prompt "https://github.com/taheryhaia2/chatbot-based-on-rag-architecture/blob/master/chat.py"
click node_auth "https://github.com/taheryhaia2/chatbot-based-on-rag-architecture/blob/master/chat.py"
click node_users "https://github.com/taheryhaia2/chatbot-based-on-rag-architecture/blob/master/chat.py"
click node_history "https://github.com/taheryhaia2/chatbot-based-on-rag-architecture/blob/master/chat.py"
click node_sessions "https://github.com/taheryhaia2/chatbot-based-on-rag-architecture/blob/master/chat.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_question,node_sources,node_speech,node_staff toneBlue
class node_pdf,node_chunking,node_index,node_chroma,node_hybrid,node_prompt toneAmber
class node_auth,node_users,node_history,node_sessions toneMint
class node_ollama,node_gtts toneRose
```

## Components

### Chat Interface

- [Streamlit app](https://github.com/taheryhaia2/chatbot-based-on-rag-architecture/blob/master/chat.py): `chat.py`
- [Question handling](https://github.com/taheryhaia2/chatbot-based-on-rag-architecture/blob/master/chat.py): `chat.py`
- [Source display](https://github.com/taheryhaia2/chatbot-based-on-rag-architecture/blob/master/chat.py): `chat.py`
- [Speech output](https://github.com/taheryhaia2/chatbot-based-on-rag-architecture/blob/master/chat.py): `chat.py`

### Document RAG

- [PDF ingestion](https://github.com/taheryhaia2/chatbot-based-on-rag-architecture/blob/master/chat.py): `chat.py`
- [Semantic chunking](https://github.com/taheryhaia2/chatbot-based-on-rag-architecture/blob/master/chat.py): `chat.py`
- [Vector indexing](https://github.com/taheryhaia2/chatbot-based-on-rag-architecture/blob/master/chat.py): `chat.py`
- [Chroma index](https://github.com/taheryhaia2/chatbot-based-on-rag-architecture/blob/master/chat.py): `chat.py`
- [Hybrid retrieval](https://github.com/taheryhaia2/chatbot-based-on-rag-architecture/blob/master/chat.py): `chat.py`
- [Context prompt](https://github.com/taheryhaia2/chatbot-based-on-rag-architecture/blob/master/chat.py): `chat.py`

### Identity And History

- [Authentication](https://github.com/taheryhaia2/chatbot-based-on-rag-architecture/blob/master/chat.py): `chat.py`
- [User records](https://github.com/taheryhaia2/chatbot-based-on-rag-architecture/blob/master/chat.py): `chat.py`
- [Chat history](https://github.com/taheryhaia2/chatbot-based-on-rag-architecture/blob/master/chat.py): `chat.py`
- [Session records](https://github.com/taheryhaia2/chatbot-based-on-rag-architecture/blob/master/chat.py): `chat.py`

### Runtime Integrations

- **Ollama models**
- **gTTS service**

### Other components

- **Staff user**

## Connections

- Staff user → Streamlit app: uses
- Streamlit app → Authentication: authenticates
- Authentication → User records: reads / writes
- Streamlit app → PDF ingestion: uploads PDF
- PDF ingestion → Semantic chunking: extracts text
- Semantic chunking → Vector indexing: creates chunks
- Vector indexing → Ollama models: embeds with
- Vector indexing → Chroma index: stores vectors
- Streamlit app → Question handling: submits question
- Question handling → Hybrid retrieval: retrieves context
- Hybrid retrieval → Chroma index: searches vectors
- Question handling → Context prompt: formats context
- Context prompt → Ollama models: requests answer
- Question handling → Source display: provides sources
- Streamlit app → Chat history: manages sessions
- Chat history → Session records: reads / writes
- Streamlit app → Speech output: optionally speaks
- Speech output → gTTS service: generates audio
