# rakeshganapathy/enterprise-rag-assistant architecture

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

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

## Overview

This repository implements an enterprise RAG knowledge assistant: users ask questions through a Streamlit UI or API, receive access-filtered answers with citations, and can submit feedback. The central answer path routes queries into semantic or hybrid retrieval, reranks evidence, checks a context-based answer cache, and on misses runs a LangGraph retrieve/grade/rewrite/generate/ground workflow with conversation history. Separate capabilities ingest documents (including S3 events), manage feedback, and evaluate answer quality. The README documents several integrations whose detailed wiring is not present in the sampled source.

Main entry points: [`app/retrieval/qa.py`](https://github.com/rakeshganapathy/enterprise-rag-assistant/blob/main/app/retrieval/qa.py) (QA orchestration), [`app/main.py`](https://github.com/rakeshganapathy/enterprise-rag-assistant/blob/main/app/main.py) (FastAPI endpoints), [`app/ingestion/pipeline.py`](https://github.com/rakeshganapathy/enterprise-rag-assistant/blob/main/app/ingestion/pipeline.py) (Ingestion pipeline), [`app/db.py`](https://github.com/rakeshganapathy/enterprise-rag-assistant/blob/main/app/db.py) (PostgreSQL pgvector)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_interfaces["User interfaces"]
  node_streamlit["Chat UI<br/>[streamlit_app.py]"]
  node_api["FastAPI endpoints<br/>[main.py]"]
end

subgraph group_security["Identity and access"]
  node_jwt["JWT and limits<br/>[dependencies.py]"]
  node_rbac["Access filters<br/>[rbac.py]"]
end

subgraph group_answering["Retrieval and answering"]
  node_router["Query router<br/>[query_router.py]"]
  node_qa["QA orchestration<br/>[qa.py]"]
  node_hybrid["Hybrid search<br/>[hybrid_search.py]"]
  node_vector["Vector search<br/>[vector_store.py]"]
  node_reranker["Cross-encoder<br/>[reranker.py]"]
  node_cache[("Answer cache<br/>[query_cache.py]")]
  node_workflow["RAG workflow<br/>[workflow.py]"]
  node_graphnodes["Workflow stages<br/>[nodes.py]"]
  node_llm["LLM and embeddings<br/>[llm.py]"]
  node_conversation[("Conversation history<br/>[store.py]")]
end

subgraph group_knowledge["Knowledge lifecycle"]
  node_pgvector[("PostgreSQL pgvector<br/>[db.py]")]
  node_ingest["Ingestion pipeline<br/>[pipeline.py]"]
  node_loaders["Document loaders<br/>[loaders.py]"]
  node_chunking["Chunking<br/>[chunking.py]"]
  node_documents[("Document records<br/>[document_store.py]")]
  node_s3lambda["S3 event Lambda"]
end

subgraph group_operations["Quality and feedback"]
  node_feedback[("Feedback store<br/>[store.py]")]
  node_evaluation["RAGAS evaluation<br/>[runner.py]"]
end

node_user(("Questioner"))
node_s3[("S3 bucket")]
node_openai(("OpenAI-compatible service"))

node_user -->|"asks questions"| node_streamlit
node_streamlit -->|"calls API"| node_api
node_user -->|"submits requests"| node_api
node_api -->|"checks claims"| node_jwt
node_jwt -->|"builds access filter"| node_rbac
node_api -->|"requests answer"| node_qa
node_api -->|"requests ingestion"| node_ingest
node_api -->|"stores feedback"| node_feedback
node_qa -->|"selects mode"| node_router
node_qa -->|"requests retrieval"| node_hybrid
node_qa -->|"requests retrieval"| node_vector
node_hybrid -->|"runs dense search"| node_vector
node_qa -->|"reranks results"| node_reranker
node_qa -->|"checks and stores"| node_cache
node_qa -->|"runs on cache miss"| node_workflow
node_workflow -->|"dispatches stages"| node_graphnodes
node_graphnodes -->|"retrieves context"| node_qa
node_graphnodes -->|"rewrites and generates"| node_llm
node_graphnodes -->|"reads history"| node_conversation
node_graphnodes -->|"reads history"| node_pgvector
node_vector -->|"searches chunks"| node_pgvector
node_cache -->|"reads and writes"| node_pgvector
node_conversation -->|"reads and writes"| node_pgvector
node_ingest -->|"extracts content"| node_loaders
node_ingest -->|"splits documents"| node_chunking
node_ingest -->|"embeds chunks"| node_llm
node_ingest -->|"indexes chunks"| node_vector
node_ingest -->|"tracks versions"| node_documents
node_documents -->|"stores records"| node_pgvector
node_s3 -.->|"sends events"| node_s3lambda
node_s3lambda -.->|"reads tags and signs URL"| node_s3
node_s3lambda -.->|"posts ingest event"| node_api
node_ingest -.->|"downloads object"| node_s3
node_llm -.->|"calls model services"| node_openai
node_api -.->|"evaluation capability"| node_evaluation
node_evaluation -.->|"runs questions through"| node_qa
node_feedback -->|"stores and reads"| node_pgvector

click node_streamlit "https://github.com/rakeshganapathy/enterprise-rag-assistant/blob/main/streamlit_app.py"
click node_api "https://github.com/rakeshganapathy/enterprise-rag-assistant/blob/main/app/main.py"
click node_jwt "https://github.com/rakeshganapathy/enterprise-rag-assistant/blob/main/app/auth/dependencies.py"
click node_rbac "https://github.com/rakeshganapathy/enterprise-rag-assistant/blob/main/app/access/rbac.py"
click node_router "https://github.com/rakeshganapathy/enterprise-rag-assistant/blob/main/app/retrieval/query_router.py"
click node_qa "https://github.com/rakeshganapathy/enterprise-rag-assistant/blob/main/app/retrieval/qa.py"
click node_hybrid "https://github.com/rakeshganapathy/enterprise-rag-assistant/blob/main/app/retrieval/hybrid_search.py"
click node_vector "https://github.com/rakeshganapathy/enterprise-rag-assistant/blob/main/app/retrieval/vector_store.py"
click node_reranker "https://github.com/rakeshganapathy/enterprise-rag-assistant/blob/main/app/retrieval/reranker.py"
click node_cache "https://github.com/rakeshganapathy/enterprise-rag-assistant/blob/main/app/cache/query_cache.py"
click node_workflow "https://github.com/rakeshganapathy/enterprise-rag-assistant/blob/main/app/graph/workflow.py"
click node_graphnodes "https://github.com/rakeshganapathy/enterprise-rag-assistant/blob/main/app/graph/nodes.py"
click node_llm "https://github.com/rakeshganapathy/enterprise-rag-assistant/blob/main/app/llm.py"
click node_conversation "https://github.com/rakeshganapathy/enterprise-rag-assistant/blob/main/app/conversation/store.py"
click node_pgvector "https://github.com/rakeshganapathy/enterprise-rag-assistant/blob/main/app/db.py"
click node_ingest "https://github.com/rakeshganapathy/enterprise-rag-assistant/blob/main/app/ingestion/pipeline.py"
click node_loaders "https://github.com/rakeshganapathy/enterprise-rag-assistant/blob/main/app/ingestion/loaders.py"
click node_chunking "https://github.com/rakeshganapathy/enterprise-rag-assistant/blob/main/app/ingestion/chunking.py"
click node_documents "https://github.com/rakeshganapathy/enterprise-rag-assistant/blob/main/app/ingestion/document_store.py"
click node_s3lambda "https://github.com/rakeshganapathy/enterprise-rag-assistant/blob/main/lambda/s3_ingest_trigger.py"
click node_feedback "https://github.com/rakeshganapathy/enterprise-rag-assistant/blob/main/app/feedback/store.py"
click node_evaluation "https://github.com/rakeshganapathy/enterprise-rag-assistant/blob/main/app/evaluation/runner.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_streamlit,node_api toneBlue
class node_jwt,node_rbac,node_s3 toneAmber
class node_router,node_qa,node_hybrid,node_vector,node_reranker,node_cache,node_workflow,node_graphnodes,node_llm,node_conversation toneMint
class node_pgvector,node_ingest,node_loaders,node_chunking,node_documents,node_s3lambda toneRose
class node_feedback,node_evaluation,node_user,node_openai toneIndigo
```

## Components

### User interfaces

- [Chat UI](https://github.com/rakeshganapathy/enterprise-rag-assistant/blob/main/streamlit_app.py): `streamlit_app.py`
- [FastAPI endpoints](https://github.com/rakeshganapathy/enterprise-rag-assistant/blob/main/app/main.py): `app/main.py`

### Identity and access

- [JWT and limits](https://github.com/rakeshganapathy/enterprise-rag-assistant/blob/main/app/auth/dependencies.py): `app/auth/dependencies.py`
- [Access filters](https://github.com/rakeshganapathy/enterprise-rag-assistant/blob/main/app/access/rbac.py): `app/access/rbac.py`

### Retrieval and answering

- [Query router](https://github.com/rakeshganapathy/enterprise-rag-assistant/blob/main/app/retrieval/query_router.py): `app/retrieval/query_router.py`
- [QA orchestration](https://github.com/rakeshganapathy/enterprise-rag-assistant/blob/main/app/retrieval/qa.py): `app/retrieval/qa.py`
- [Hybrid search](https://github.com/rakeshganapathy/enterprise-rag-assistant/blob/main/app/retrieval/hybrid_search.py): `app/retrieval/hybrid_search.py`
- [Vector search](https://github.com/rakeshganapathy/enterprise-rag-assistant/blob/main/app/retrieval/vector_store.py): `app/retrieval/vector_store.py`
- [Cross-encoder](https://github.com/rakeshganapathy/enterprise-rag-assistant/blob/main/app/retrieval/reranker.py): `app/retrieval/reranker.py`
- [Answer cache](https://github.com/rakeshganapathy/enterprise-rag-assistant/blob/main/app/cache/query_cache.py): `app/cache/query_cache.py`
- [RAG workflow](https://github.com/rakeshganapathy/enterprise-rag-assistant/blob/main/app/graph/workflow.py): `app/graph/workflow.py`
- [Workflow stages](https://github.com/rakeshganapathy/enterprise-rag-assistant/blob/main/app/graph/nodes.py): `app/graph/nodes.py`
- [LLM and embeddings](https://github.com/rakeshganapathy/enterprise-rag-assistant/blob/main/app/llm.py): `app/llm.py`
- [Conversation history](https://github.com/rakeshganapathy/enterprise-rag-assistant/blob/main/app/conversation/store.py): `app/conversation/store.py`

### Knowledge lifecycle

- [PostgreSQL pgvector](https://github.com/rakeshganapathy/enterprise-rag-assistant/blob/main/app/db.py): `app/db.py`
- [Ingestion pipeline](https://github.com/rakeshganapathy/enterprise-rag-assistant/blob/main/app/ingestion/pipeline.py): `app/ingestion/pipeline.py`
- [Document loaders](https://github.com/rakeshganapathy/enterprise-rag-assistant/blob/main/app/ingestion/loaders.py): `app/ingestion/loaders.py`
- [Chunking](https://github.com/rakeshganapathy/enterprise-rag-assistant/blob/main/app/ingestion/chunking.py): `app/ingestion/chunking.py`
- [Document records](https://github.com/rakeshganapathy/enterprise-rag-assistant/blob/main/app/ingestion/document_store.py): `app/ingestion/document_store.py`
- [S3 event Lambda](https://github.com/rakeshganapathy/enterprise-rag-assistant/blob/main/lambda/s3_ingest_trigger.py): `lambda/s3_ingest_trigger.py`

### Quality and feedback

- [Feedback store](https://github.com/rakeshganapathy/enterprise-rag-assistant/blob/main/app/feedback/store.py): `app/feedback/store.py`
- [RAGAS evaluation](https://github.com/rakeshganapathy/enterprise-rag-assistant/blob/main/app/evaluation/runner.py): `app/evaluation/runner.py`

### Other components

- **Questioner**
- **S3 bucket**
- **OpenAI-compatible service**

## Connections

- Questioner → Chat UI: asks questions
- Chat UI → FastAPI endpoints: calls API
- Questioner → FastAPI endpoints: submits requests
- FastAPI endpoints → JWT and limits: checks claims
- JWT and limits → Access filters: builds access filter
- FastAPI endpoints → QA orchestration: requests answer
- FastAPI endpoints → Ingestion pipeline: requests ingestion
- FastAPI endpoints → Feedback store: stores feedback
- QA orchestration → Query router: selects mode
- QA orchestration → Hybrid search: requests retrieval
- QA orchestration → Vector search: requests retrieval
- Hybrid search → Vector search: runs dense search
- QA orchestration → Cross-encoder: reranks results
- QA orchestration → Answer cache: checks and stores
- QA orchestration → RAG workflow: runs on cache miss
- RAG workflow → Workflow stages: dispatches stages
- Workflow stages → QA orchestration: retrieves context
- Workflow stages → LLM and embeddings: rewrites and generates
- Workflow stages → Conversation history: reads history
- Workflow stages → PostgreSQL pgvector: reads history
- Vector search → PostgreSQL pgvector: searches chunks
- Answer cache → PostgreSQL pgvector: reads and writes
- Conversation history → PostgreSQL pgvector: reads and writes
- Ingestion pipeline → Document loaders: extracts content
- Ingestion pipeline → Chunking: splits documents
- Ingestion pipeline → LLM and embeddings: embeds chunks
- Ingestion pipeline → Vector search: indexes chunks
- Ingestion pipeline → Document records: tracks versions
- Document records → PostgreSQL pgvector: stores records
- S3 bucket → S3 event Lambda: sends events
- S3 event Lambda → S3 bucket: reads tags and signs URL
- S3 event Lambda → FastAPI endpoints: posts ingest event
- Ingestion pipeline → S3 bucket: downloads object
- LLM and embeddings → OpenAI-compatible service: calls model services
- FastAPI endpoints → RAGAS evaluation: evaluation capability
- RAGAS evaluation → QA orchestration: runs questions through
- Feedback store → PostgreSQL pgvector: stores and reads
