# ksganni/enterprise-rag-knowledge-assistant architecture

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

- Interactive diagram: https://gitdiagram.com/ksganni/enterprise-rag-knowledge-assistant
- Repository: https://github.com/ksganni/enterprise-rag-knowledge-assistant

## Overview

This is an enterprise RAG knowledge assistant. Employees use the Streamlit dashboard to load or upload a policy document, choose it, and ask a question; the API ingests and indexes documents or orchestrates retrieval and answer generation, then returns source-attributed results. The graph also includes document inventory and deletion. Relationships are based on the shown source calls and README descriptions; unsampled dashboard behavior is represented only where documented.

Main entry points: [`app/main.py`](https://github.com/ksganni/enterprise-rag-knowledge-assistant/blob/main/app/main.py) (FastAPI endpoints), [`app/rag/chain.py`](https://github.com/ksganni/enterprise-rag-knowledge-assistant/blob/main/app/rag/chain.py) (Question orchestration), [`frontend/streamlit_app.py`](https://github.com/ksganni/enterprise-rag-knowledge-assistant/blob/main/frontend/streamlit_app.py) (Streamlit dashboard), [`app/rag/vectorstore.py`](https://github.com/ksganni/enterprise-rag-knowledge-assistant/blob/main/app/rag/vectorstore.py) (Chroma vector index)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_presentation["User interface"]
  node_dashboard["Streamlit dashboard<br/>[streamlit_app.py]"]
  node_sample_corpus["Sample policy corpus"]
end

subgraph group_api["API and contracts"]
  node_rest_api["FastAPI endpoints<br/>[main.py]"]
  node_api_schemas["Request and response schemas<br/>[schemas.py]"]
  node_source_response["Answer and source attribution<br/>[main.py]"]
end

subgraph group_ingestion["Document ingestion"]
  node_uploaded_files[("Uploaded documents<br/>[config.py]")]
  node_document_loader["Document parsing<br/>[ingest.py]"]
  node_chunker["Text chunking<br/>[ingest.py]"]
end

subgraph group_knowledge["Search and storage"]
  node_embeddings["FastEmbed embeddings<br/>[vectorstore.py]"]
  node_vector_index[("Chroma vector index<br/>[vectorstore.py]")]
  node_document_catalog[("Indexed document inventory<br/>[vectorstore.py]")]
end

subgraph group_answering["Answer generation"]
  node_retrieval["Semantic retrieval<br/>[vectorstore.py]"]
  node_rag_orchestrator["Question orchestration<br/>[chain.py]"]
  node_context_fallback["Context and passage fallback<br/>[chain.py]"]
  node_gemini{{"Google Gemini"}}
end

node_employee(("Employee"))

node_employee -->|"uses"| node_dashboard
node_dashboard -->|"loads samples"| node_sample_corpus
node_dashboard -->|"calls HTTP API"| node_rest_api
node_rest_api -->|"validates and returns"| node_api_schemas
node_rest_api -->|"writes and deletes"| node_uploaded_files
node_rest_api -->|"loads documents"| node_document_loader
node_document_loader -->|"splits text"| node_chunker
node_rest_api -->|"chunks documents"| node_chunker
node_rest_api -->|"indexes chunks"| node_vector_index
node_embeddings -->|"encodes vectors"| node_vector_index
node_rest_api -->|"lists and deletes"| node_document_catalog
node_rag_orchestrator -->|"searches chunks"| node_retrieval
node_retrieval -->|"searches index"| node_vector_index
node_rag_orchestrator -->|"formats passages"| node_context_fallback
node_rag_orchestrator -->|"requests generation"| node_gemini
node_context_fallback -->|"provides context"| node_gemini
node_rest_api -->|"asks question"| node_rag_orchestrator
node_rest_api -->|"attributes sources"| node_source_response
node_rag_orchestrator -->|"returns answer and passages"| node_source_response
node_source_response -->|"delivers results"| node_dashboard

click node_dashboard "https://github.com/ksganni/enterprise-rag-knowledge-assistant/blob/main/frontend/streamlit_app.py"
click node_sample_corpus "https://github.com/ksganni/enterprise-rag-knowledge-assistant/tree/main/data/sample_docs"
click node_rest_api "https://github.com/ksganni/enterprise-rag-knowledge-assistant/blob/main/app/main.py"
click node_api_schemas "https://github.com/ksganni/enterprise-rag-knowledge-assistant/blob/main/app/schemas.py"
click node_uploaded_files "https://github.com/ksganni/enterprise-rag-knowledge-assistant/blob/main/app/config.py"
click node_document_loader "https://github.com/ksganni/enterprise-rag-knowledge-assistant/blob/main/app/rag/ingest.py"
click node_chunker "https://github.com/ksganni/enterprise-rag-knowledge-assistant/blob/main/app/rag/ingest.py"
click node_embeddings "https://github.com/ksganni/enterprise-rag-knowledge-assistant/blob/main/app/rag/vectorstore.py"
click node_vector_index "https://github.com/ksganni/enterprise-rag-knowledge-assistant/blob/main/app/rag/vectorstore.py"
click node_document_catalog "https://github.com/ksganni/enterprise-rag-knowledge-assistant/blob/main/app/rag/vectorstore.py"
click node_retrieval "https://github.com/ksganni/enterprise-rag-knowledge-assistant/blob/main/app/rag/vectorstore.py"
click node_rag_orchestrator "https://github.com/ksganni/enterprise-rag-knowledge-assistant/blob/main/app/rag/chain.py"
click node_context_fallback "https://github.com/ksganni/enterprise-rag-knowledge-assistant/blob/main/app/rag/chain.py"
click node_source_response "https://github.com/ksganni/enterprise-rag-knowledge-assistant/blob/main/app/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_dashboard,node_sample_corpus toneBlue
class node_rest_api,node_api_schemas,node_source_response toneAmber
class node_uploaded_files,node_document_loader,node_chunker toneMint
class node_embeddings,node_vector_index,node_document_catalog toneRose
class node_retrieval,node_rag_orchestrator,node_context_fallback,node_gemini,node_employee toneIndigo
```

## Components

### User interface

- [Streamlit dashboard](https://github.com/ksganni/enterprise-rag-knowledge-assistant/blob/main/frontend/streamlit_app.py): `frontend/streamlit_app.py`
- [Sample policy corpus](https://github.com/ksganni/enterprise-rag-knowledge-assistant/tree/main/data/sample_docs): `data/sample_docs`

### API and contracts

- [FastAPI endpoints](https://github.com/ksganni/enterprise-rag-knowledge-assistant/blob/main/app/main.py): `app/main.py`
- [Request and response schemas](https://github.com/ksganni/enterprise-rag-knowledge-assistant/blob/main/app/schemas.py): `app/schemas.py`
- [Answer and source attribution](https://github.com/ksganni/enterprise-rag-knowledge-assistant/blob/main/app/main.py): `app/main.py`

### Document ingestion

- [Uploaded documents](https://github.com/ksganni/enterprise-rag-knowledge-assistant/blob/main/app/config.py): `app/config.py`
- [Document parsing](https://github.com/ksganni/enterprise-rag-knowledge-assistant/blob/main/app/rag/ingest.py): `app/rag/ingest.py`
- [Text chunking](https://github.com/ksganni/enterprise-rag-knowledge-assistant/blob/main/app/rag/ingest.py): `app/rag/ingest.py`

### Search and storage

- [FastEmbed embeddings](https://github.com/ksganni/enterprise-rag-knowledge-assistant/blob/main/app/rag/vectorstore.py): `app/rag/vectorstore.py`
- [Chroma vector index](https://github.com/ksganni/enterprise-rag-knowledge-assistant/blob/main/app/rag/vectorstore.py): `app/rag/vectorstore.py`
- [Indexed document inventory](https://github.com/ksganni/enterprise-rag-knowledge-assistant/blob/main/app/rag/vectorstore.py): `app/rag/vectorstore.py`

### Answer generation

- [Semantic retrieval](https://github.com/ksganni/enterprise-rag-knowledge-assistant/blob/main/app/rag/vectorstore.py): `app/rag/vectorstore.py`
- [Question orchestration](https://github.com/ksganni/enterprise-rag-knowledge-assistant/blob/main/app/rag/chain.py): `app/rag/chain.py`
- [Context and passage fallback](https://github.com/ksganni/enterprise-rag-knowledge-assistant/blob/main/app/rag/chain.py): `app/rag/chain.py`
- **Google Gemini**

### Other components

- **Employee**

## Connections

- Employee → Streamlit dashboard: uses (evidence: `README.md`)
- Streamlit dashboard → Sample policy corpus: loads samples (evidence: `README.md`)
- Streamlit dashboard → FastAPI endpoints: calls HTTP API (evidence: `frontend/streamlit_app.py`)
- FastAPI endpoints → Request and response schemas: validates and returns (evidence: `app/main.py`)
- FastAPI endpoints → Uploaded documents: writes and deletes (evidence: `app/main.py`)
- FastAPI endpoints → Document parsing: loads documents (evidence: `app/main.py`)
- Document parsing → Text chunking: splits text (evidence: `app/rag/ingest.py`)
- FastAPI endpoints → Text chunking: chunks documents (evidence: `app/main.py`)
- FastAPI endpoints → Chroma vector index: indexes chunks (evidence: `app/main.py`)
- FastEmbed embeddings → Chroma vector index: encodes vectors (evidence: `app/rag/vectorstore.py`)
- FastAPI endpoints → Indexed document inventory: lists and deletes (evidence: `app/main.py`)
- Question orchestration → Semantic retrieval: searches chunks (evidence: `app/rag/chain.py`)
- Semantic retrieval → Chroma vector index: searches index (evidence: `app/rag/vectorstore.py`)
- Question orchestration → Context and passage fallback: formats passages (evidence: `app/rag/chain.py`)
- Question orchestration → Google Gemini: requests generation (evidence: `app/rag/chain.py`)
- Context and passage fallback → Google Gemini: provides context (evidence: `app/rag/chain.py`)
- FastAPI endpoints → Question orchestration: asks question (evidence: `app/main.py`)
- FastAPI endpoints → Answer and source attribution: attributes sources (evidence: `app/main.py`)
- Question orchestration → Answer and source attribution: returns answer and passages (evidence: `app/main.py`)
- Answer and source attribution → Streamlit dashboard: delivers results (evidence: `README.md`)
