# divakar-star/customer-support-rag-assistant architecture

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

- Interactive diagram: https://gitdiagram.com/divakar-star/customer-support-rag-assistant
- Repository: https://github.com/divakar-star/customer-support-rag-assistant

## Overview

This is a local-first support-document RAG assistant. Its main workflows are document upload/ingestion into FAISS and SQLite, and chat through semantic retrieval, confidence-based refusal, context assembly, Gemini generation, and citation validation. The graph retains the documented UI and ingestion-script entry points and the distinct ingestion and answer-generation stages. Source excerpts establish the principal calls; README statements support the documented user workflow. Unsampled UI and loader internals are not expanded, and no unverified UI-to-API call is asserted.

Main entry points: [`app/ingestion/pipeline.py`](https://github.com/divakar-star/customer-support-rag-assistant/blob/main/app/ingestion/pipeline.py) (Ingestion orchestrator), [`app/rag/pipeline.py`](https://github.com/divakar-star/customer-support-rag-assistant/blob/main/app/rag/pipeline.py) (Answer orchestrator), [`app/main.py`](https://github.com/divakar-star/customer-support-rag-assistant/blob/main/app/main.py) (FastAPI app), [`app/retrieval/vector_search.py`](https://github.com/divakar-star/customer-support-rag-assistant/blob/main/app/retrieval/vector_search.py) (Vector retrieval)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["User entry points"]
  node_ui["Streamlit UI<br/>[streamlit_app.py]"]
  node_api["FastAPI app<br/>[main.py]"]
  node_chat_route["Chat endpoint<br/>[routes_chat.py]"]
  node_document_route["Document endpoint"]
  node_ingest_script["Ingestion script"]
end

subgraph group_ingestion["Document ingestion"]
  node_ingest["Ingestion orchestrator<br/>[pipeline.py]"]
  node_loader["Document loader<br/>[loader.py]"]
  node_cleaner["Text cleaner<br/>[cleaner.py]"]
  node_chunker["Page chunker<br/>[chunker.py]"]
  node_embed["Embedding service<br/>[model.py]"]
end

subgraph group_answering["Answer pipeline"]
  node_rag["Answer orchestrator<br/>[pipeline.py]"]
  node_retrieval["Vector retrieval<br/>[vector_search.py]"]
  node_context["Context builder<br/>[context_builder.py]"]
  node_prompts["Prompt builder<br/>[prompts.py]"]
  node_generator["LLM generator<br/>[generator.py]"]
  node_citations["Citation validator<br/>[citations.py]"]
end

subgraph group_persistence["Search and storage"]
  node_faiss[("FAISS index<br/>[faiss_store.py]")]
  node_repository["Document repository"]
  node_sqlite[("SQLite database<br/>[sqlite.py]")]
  node_config["Runtime settings<br/>[config.py]"]
end

node_user(("Support user"))
node_gemini["Google Gemini"]

node_user -->|"uses"| node_ui
node_user -->|"submits requests"| node_api
node_api -->|"registers"| node_chat_route
node_api -->|"registers"| node_document_route
node_document_route -->|"ingests upload"| node_ingest
node_ingest_script -->|"runs ingestion"| node_ingest
node_ingest -->|"loads files"| node_loader
node_ingest -->|"cleans text"| node_cleaner
node_ingest -->|"chunks pages"| node_chunker
node_ingest -->|"embeds chunks"| node_embed
node_ingest -->|"writes document and chunks"| node_repository
node_ingest -->|"adds vectors"| node_faiss
node_chat_route -->|"answers question"| node_rag
node_rag -->|"searches query"| node_retrieval
node_retrieval -->|"embeds query"| node_embed
node_retrieval -->|"searches vectors"| node_faiss
node_retrieval -->|"loads chunk metadata"| node_repository
node_rag -->|"builds context"| node_context
node_rag -->|"builds prompt"| node_prompts
node_rag -->|"generates answer"| node_generator
node_generator -->|"calls model"| node_gemini
node_rag -->|"validates citations"| node_citations
node_repository -->|"queries and writes"| node_sqlite
node_api -->|"initializes schema"| node_sqlite
node_faiss -->|"reads index paths"| node_config
node_sqlite -->|"reads database path"| node_config
node_embed -->|"reads model setting"| node_config
node_rag -->|"reads retrieval threshold"| node_config

click node_ui "https://github.com/divakar-star/customer-support-rag-assistant/blob/main/ui/streamlit_app.py"
click node_api "https://github.com/divakar-star/customer-support-rag-assistant/blob/main/app/main.py"
click node_chat_route "https://github.com/divakar-star/customer-support-rag-assistant/blob/main/app/api/routes_chat.py"
click node_document_route "https://github.com/divakar-star/customer-support-rag-assistant/blob/main/app/api/routes_documents.py"
click node_ingest_script "https://github.com/divakar-star/customer-support-rag-assistant/blob/main/scripts/ingest_documents.py"
click node_ingest "https://github.com/divakar-star/customer-support-rag-assistant/blob/main/app/ingestion/pipeline.py"
click node_loader "https://github.com/divakar-star/customer-support-rag-assistant/blob/main/app/ingestion/loader.py"
click node_cleaner "https://github.com/divakar-star/customer-support-rag-assistant/blob/main/app/ingestion/cleaner.py"
click node_chunker "https://github.com/divakar-star/customer-support-rag-assistant/blob/main/app/ingestion/chunker.py"
click node_embed "https://github.com/divakar-star/customer-support-rag-assistant/blob/main/app/embeddings/model.py"
click node_rag "https://github.com/divakar-star/customer-support-rag-assistant/blob/main/app/rag/pipeline.py"
click node_retrieval "https://github.com/divakar-star/customer-support-rag-assistant/blob/main/app/retrieval/vector_search.py"
click node_context "https://github.com/divakar-star/customer-support-rag-assistant/blob/main/app/rag/context_builder.py"
click node_prompts "https://github.com/divakar-star/customer-support-rag-assistant/blob/main/app/rag/prompts.py"
click node_generator "https://github.com/divakar-star/customer-support-rag-assistant/blob/main/app/rag/generator.py"
click node_citations "https://github.com/divakar-star/customer-support-rag-assistant/blob/main/app/rag/citations.py"
click node_faiss "https://github.com/divakar-star/customer-support-rag-assistant/blob/main/app/storage/faiss_store.py"
click node_repository "https://github.com/divakar-star/customer-support-rag-assistant/blob/main/app/storage/document_repository.py"
click node_sqlite "https://github.com/divakar-star/customer-support-rag-assistant/blob/main/app/storage/sqlite.py"
click node_config "https://github.com/divakar-star/customer-support-rag-assistant/blob/main/app/core/config.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_api,node_chat_route,node_document_route,node_ingest_script,node_user toneBlue
class node_ingest,node_loader,node_cleaner,node_chunker,node_embed toneAmber
class node_rag,node_retrieval,node_context,node_prompts,node_generator,node_citations toneMint
class node_faiss,node_repository,node_sqlite,node_config toneRose
class node_gemini toneIndigo
```

## Components

### User entry points

- [Streamlit UI](https://github.com/divakar-star/customer-support-rag-assistant/blob/main/ui/streamlit_app.py): `ui/streamlit_app.py`
- [FastAPI app](https://github.com/divakar-star/customer-support-rag-assistant/blob/main/app/main.py): `app/main.py`
- [Chat endpoint](https://github.com/divakar-star/customer-support-rag-assistant/blob/main/app/api/routes_chat.py): `app/api/routes_chat.py`
- [Document endpoint](https://github.com/divakar-star/customer-support-rag-assistant/blob/main/app/api/routes_documents.py): `app/api/routes_documents.py`
- [Ingestion script](https://github.com/divakar-star/customer-support-rag-assistant/blob/main/scripts/ingest_documents.py): `scripts/ingest_documents.py`

### Document ingestion

- [Ingestion orchestrator](https://github.com/divakar-star/customer-support-rag-assistant/blob/main/app/ingestion/pipeline.py): `app/ingestion/pipeline.py`
- [Document loader](https://github.com/divakar-star/customer-support-rag-assistant/blob/main/app/ingestion/loader.py): `app/ingestion/loader.py`
- [Text cleaner](https://github.com/divakar-star/customer-support-rag-assistant/blob/main/app/ingestion/cleaner.py): `app/ingestion/cleaner.py`
- [Page chunker](https://github.com/divakar-star/customer-support-rag-assistant/blob/main/app/ingestion/chunker.py): `app/ingestion/chunker.py`
- [Embedding service](https://github.com/divakar-star/customer-support-rag-assistant/blob/main/app/embeddings/model.py): `app/embeddings/model.py`

### Answer pipeline

- [Answer orchestrator](https://github.com/divakar-star/customer-support-rag-assistant/blob/main/app/rag/pipeline.py): `app/rag/pipeline.py`
- [Vector retrieval](https://github.com/divakar-star/customer-support-rag-assistant/blob/main/app/retrieval/vector_search.py): `app/retrieval/vector_search.py`
- [Context builder](https://github.com/divakar-star/customer-support-rag-assistant/blob/main/app/rag/context_builder.py): `app/rag/context_builder.py`
- [Prompt builder](https://github.com/divakar-star/customer-support-rag-assistant/blob/main/app/rag/prompts.py): `app/rag/prompts.py`
- [LLM generator](https://github.com/divakar-star/customer-support-rag-assistant/blob/main/app/rag/generator.py): `app/rag/generator.py`
- [Citation validator](https://github.com/divakar-star/customer-support-rag-assistant/blob/main/app/rag/citations.py): `app/rag/citations.py`

### Search and storage

- [FAISS index](https://github.com/divakar-star/customer-support-rag-assistant/blob/main/app/storage/faiss_store.py): `app/storage/faiss_store.py`
- [Document repository](https://github.com/divakar-star/customer-support-rag-assistant/blob/main/app/storage/document_repository.py): `app/storage/document_repository.py`
- [SQLite database](https://github.com/divakar-star/customer-support-rag-assistant/blob/main/app/storage/sqlite.py): `app/storage/sqlite.py`
- [Runtime settings](https://github.com/divakar-star/customer-support-rag-assistant/blob/main/app/core/config.py): `app/core/config.py`

### Other components

- **Support user**
- **Google Gemini**

## Connections

- Support user → Streamlit UI: uses (evidence: `README.md`)
- Support user → FastAPI app: submits requests (evidence: `README.md`)
- FastAPI app → Chat endpoint: registers (evidence: `app/main.py`)
- FastAPI app → Document endpoint: registers (evidence: `app/main.py`)
- Document endpoint → Ingestion orchestrator: ingests upload (evidence: `app/api/routes_documents.py`)
- Ingestion script → Ingestion orchestrator: runs ingestion (evidence: `README.md`)
- Ingestion orchestrator → Document loader: loads files (evidence: `app/ingestion/pipeline.py`)
- Ingestion orchestrator → Text cleaner: cleans text (evidence: `app/ingestion/pipeline.py`)
- Ingestion orchestrator → Page chunker: chunks pages (evidence: `app/ingestion/pipeline.py`)
- Ingestion orchestrator → Embedding service: embeds chunks (evidence: `app/ingestion/pipeline.py`)
- Ingestion orchestrator → Document repository: writes document and chunks (evidence: `app/ingestion/pipeline.py`)
- Ingestion orchestrator → FAISS index: adds vectors (evidence: `app/ingestion/pipeline.py`)
- Chat endpoint → Answer orchestrator: answers question (evidence: `app/api/routes_chat.py`)
- Answer orchestrator → Vector retrieval: searches query (evidence: `app/rag/pipeline.py`)
- Vector retrieval → Embedding service: embeds query (evidence: `app/retrieval/vector_search.py`)
- Vector retrieval → FAISS index: searches vectors (evidence: `app/retrieval/vector_search.py`)
- Vector retrieval → Document repository: loads chunk metadata (evidence: `app/retrieval/vector_search.py`)
- Answer orchestrator → Context builder: builds context (evidence: `app/rag/pipeline.py`)
- Answer orchestrator → Prompt builder: builds prompt (evidence: `app/rag/pipeline.py`)
- Answer orchestrator → LLM generator: generates answer (evidence: `app/rag/pipeline.py`)
- LLM generator → Google Gemini: calls model (evidence: `README.md`)
- Answer orchestrator → Citation validator: validates citations (evidence: `app/rag/pipeline.py`)
- Document repository → SQLite database: queries and writes (evidence: `app/storage/document_repository.py`)
- FastAPI app → SQLite database: initializes schema (evidence: `app/main.py`)
- FAISS index → Runtime settings: reads index paths (evidence: `app/storage/faiss_store.py`)
- SQLite database → Runtime settings: reads database path (evidence: `app/storage/sqlite.py`)
- Embedding service → Runtime settings: reads model setting (evidence: `app/embeddings/model.py`)
- Answer orchestrator → Runtime settings: reads retrieval threshold (evidence: `app/rag/pipeline.py`)
