# harsh-up3131/enterprise-rag-platform architecture

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

- Interactive diagram: https://gitdiagram.com/harsh-up3131/enterprise-rag-platform
- Repository: https://github.com/harsh-up3131/enterprise-rag-platform

## Overview

EKIP is a multi-tenant knowledge platform whose main workflow is document upload, background indexing, then permission-aware question answering with citations or abstention. Separate branches provide authentication and organization context, conversation history, evaluation, and tenant-security checks. The README documents capabilities beyond the sampled excerpts; those are represented where the tree supports a path, but their internal call relationships are omitted when not evidenced.

Main entry points: [`app/services/query_service.py`](https://github.com/harsh-up3131/enterprise-rag-platform/blob/main/app/services/query_service.py) (Answer orchestration), [`app/services/retrieval/retriever.py`](https://github.com/harsh-up3131/enterprise-rag-platform/blob/main/app/services/retrieval/retriever.py) (Hybrid retrieval), [`app/main.py`](https://github.com/harsh-up3131/enterprise-rag-platform/blob/main/app/main.py) (FastAPI application), [`app/api/routes/documents.py`](https://github.com/harsh-up3131/enterprise-rag-platform/blob/main/app/api/routes/documents.py) (Document upload API)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_experience["User experience"]
  node_frontend["Web application<br/>[App.jsx]"]
  node_chat["Chat and evidence<br/>[Chat.jsx]"]
  node_frontend_api["Frontend API client<br/>[api.js]"]
end

subgraph group_platform["API and tenancy"]
  node_api_app["FastAPI application<br/>[main.py]"]
  node_auth_routes["Authentication routes<br/>[auth.py]"]
  node_context["Tenant request context<br/>[deps.py]"]
  node_jwt["JWT security<br/>[security.py]"]
  node_database[("Relational and vector store<br/>[database.py]")]
end

subgraph group_indexing["Document indexing"]
  node_documents_route["Document upload API<br/>[documents.py]"]
  node_object_storage["Object storage<br/>[storage.py]"]
  node_worker["Background ingestion task<br/>[tasks.py]"]
  node_ingestion["Parse, chunk, embed<br/>[pipeline.py]"]
end

subgraph group_answering["Grounded answering"]
  node_query_route["Question API<br/>[query.py]"]
  node_query_service["Answer orchestration<br/>[query_service.py]"]
  node_retrieval["Hybrid retrieval<br/>[retriever.py]"]
  node_lexical["Keyword search<br/>[lexical.py]"]
  node_dense["Vector search<br/>[dense.py]"]
  node_fusion["Rank fusion<br/>[fusion.py]"]
  node_reranker["Reranking<br/>[reranker.py]"]
  node_generation["Prompt and LLM<br/>[llm_client.py]"]
  node_citation["Citation validation"]
  node_guardrails["Input and output checks<br/>[guardrails.py]"]
end

subgraph group_trust["Trust and evaluation"]
  node_trace["Retrieval trace records<br/>[trace.py]"]
  node_eval_api["Evaluation API<br/>[eval.py]"]
  node_eval_runner["Evaluation runner<br/>[runner.py]"]
  node_security_api["Security audit API<br/>[security.py]"]
  node_isolation_check["Tenant isolation check"]
end

node_user(("User"))
node_postgres[("PostgreSQL with pgvector")]
node_llm_service{{"Ollama LLM"}}

node_user -->|"uses"| node_frontend
node_frontend -->|"requests"| node_frontend_api
node_frontend -.->|"shows"| node_chat
node_frontend_api -.->|"calls API"| node_api_app
node_api_app -->|"registers"| node_auth_routes
node_api_app -->|"registers"| node_documents_route
node_api_app -->|"registers"| node_query_route
node_auth_routes -->|"issues tokens"| node_jwt
node_context -->|"decodes tokens"| node_jwt
node_documents_route -->|"resolves identity"| node_context
node_documents_route -->|"stores uploads"| node_object_storage
node_documents_route -->|"queues indexing"| node_worker
node_worker -->|"runs task"| node_ingestion
node_ingestion -->|"reads files"| node_object_storage
node_ingestion -->|"writes chunks"| node_database
node_database -->|"connects"| node_postgres
node_query_route -->|"resolves identity"| node_context
node_query_route -->|"answers question"| node_query_service
node_query_service -->|"checks input"| node_guardrails
node_query_service -->|"retrieves evidence"| node_retrieval
node_retrieval -->|"searches terms"| node_lexical
node_retrieval -->|"searches vectors"| node_dense
node_retrieval -->|"merges ranks"| node_fusion
node_retrieval -->|"reranks candidates"| node_reranker
node_dense -->|"queries vectors"| node_database
node_lexical -->|"queries text"| node_database
node_query_service -->|"generates answer"| node_generation
node_generation -.->|"sends prompts"| node_llm_service
node_query_service -->|"validates sources"| node_citation
node_query_service -->|"checks output"| node_guardrails
node_query_service -->|"persists trace"| node_trace
node_eval_api -->|"runs evaluation"| node_eval_runner
node_security_api -->|"runs check"| node_isolation_check
node_isolation_check -.->|"tests isolation"| node_retrieval

click node_frontend "https://github.com/harsh-up3131/enterprise-rag-platform/blob/main/frontend/src/App.jsx"
click node_chat "https://github.com/harsh-up3131/enterprise-rag-platform/blob/main/frontend/src/components/Chat.jsx"
click node_frontend_api "https://github.com/harsh-up3131/enterprise-rag-platform/blob/main/frontend/src/api.js"
click node_api_app "https://github.com/harsh-up3131/enterprise-rag-platform/blob/main/app/main.py"
click node_auth_routes "https://github.com/harsh-up3131/enterprise-rag-platform/blob/main/app/api/routes/auth.py"
click node_context "https://github.com/harsh-up3131/enterprise-rag-platform/blob/main/app/core/deps.py"
click node_jwt "https://github.com/harsh-up3131/enterprise-rag-platform/blob/main/app/core/security.py"
click node_documents_route "https://github.com/harsh-up3131/enterprise-rag-platform/blob/main/app/api/routes/documents.py"
click node_object_storage "https://github.com/harsh-up3131/enterprise-rag-platform/blob/main/app/services/ingestion/storage.py"
click node_worker "https://github.com/harsh-up3131/enterprise-rag-platform/blob/main/app/workers/tasks.py"
click node_ingestion "https://github.com/harsh-up3131/enterprise-rag-platform/blob/main/app/services/ingestion/pipeline.py"
click node_database "https://github.com/harsh-up3131/enterprise-rag-platform/blob/main/app/database.py"
click node_query_route "https://github.com/harsh-up3131/enterprise-rag-platform/blob/main/app/api/routes/query.py"
click node_query_service "https://github.com/harsh-up3131/enterprise-rag-platform/blob/main/app/services/query_service.py"
click node_retrieval "https://github.com/harsh-up3131/enterprise-rag-platform/blob/main/app/services/retrieval/retriever.py"
click node_lexical "https://github.com/harsh-up3131/enterprise-rag-platform/blob/main/app/services/retrieval/lexical.py"
click node_dense "https://github.com/harsh-up3131/enterprise-rag-platform/blob/main/app/services/retrieval/dense.py"
click node_fusion "https://github.com/harsh-up3131/enterprise-rag-platform/blob/main/app/services/retrieval/fusion.py"
click node_reranker "https://github.com/harsh-up3131/enterprise-rag-platform/blob/main/app/services/retrieval/reranker.py"
click node_generation "https://github.com/harsh-up3131/enterprise-rag-platform/blob/main/app/services/generation/llm_client.py"
click node_citation "https://github.com/harsh-up3131/enterprise-rag-platform/blob/main/app/services/generation/citation_validator.py"
click node_guardrails "https://github.com/harsh-up3131/enterprise-rag-platform/blob/main/app/services/generation/guardrails.py"
click node_trace "https://github.com/harsh-up3131/enterprise-rag-platform/blob/main/app/models/trace.py"
click node_eval_api "https://github.com/harsh-up3131/enterprise-rag-platform/blob/main/app/api/routes/eval.py"
click node_eval_runner "https://github.com/harsh-up3131/enterprise-rag-platform/blob/main/app/services/evaluation/runner.py"
click node_security_api "https://github.com/harsh-up3131/enterprise-rag-platform/blob/main/app/api/routes/security.py"
click node_isolation_check "https://github.com/harsh-up3131/enterprise-rag-platform/blob/main/app/services/security/tenant_isolation_check.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_frontend,node_chat,node_frontend_api,node_user toneBlue
class node_api_app,node_auth_routes,node_context,node_jwt,node_database,node_postgres toneAmber
class node_documents_route,node_object_storage,node_worker,node_ingestion toneMint
class node_query_route,node_query_service,node_retrieval,node_lexical,node_dense,node_fusion,node_reranker,node_generation,node_citation,node_guardrails toneRose
class node_trace,node_eval_api,node_eval_runner,node_security_api,node_isolation_check,node_llm_service toneIndigo
```

## Components

### User experience

- [Web application](https://github.com/harsh-up3131/enterprise-rag-platform/blob/main/frontend/src/App.jsx): `frontend/src/App.jsx`
- [Chat and evidence](https://github.com/harsh-up3131/enterprise-rag-platform/blob/main/frontend/src/components/Chat.jsx): `frontend/src/components/Chat.jsx`
- [Frontend API client](https://github.com/harsh-up3131/enterprise-rag-platform/blob/main/frontend/src/api.js): `frontend/src/api.js`

### API and tenancy

- [FastAPI application](https://github.com/harsh-up3131/enterprise-rag-platform/blob/main/app/main.py): `app/main.py`
- [Authentication routes](https://github.com/harsh-up3131/enterprise-rag-platform/blob/main/app/api/routes/auth.py): `app/api/routes/auth.py`
- [Tenant request context](https://github.com/harsh-up3131/enterprise-rag-platform/blob/main/app/core/deps.py): `app/core/deps.py`
- [JWT security](https://github.com/harsh-up3131/enterprise-rag-platform/blob/main/app/core/security.py): `app/core/security.py`
- [Relational and vector store](https://github.com/harsh-up3131/enterprise-rag-platform/blob/main/app/database.py): `app/database.py`

### Document indexing

- [Document upload API](https://github.com/harsh-up3131/enterprise-rag-platform/blob/main/app/api/routes/documents.py): `app/api/routes/documents.py`
- [Object storage](https://github.com/harsh-up3131/enterprise-rag-platform/blob/main/app/services/ingestion/storage.py): `app/services/ingestion/storage.py`
- [Background ingestion task](https://github.com/harsh-up3131/enterprise-rag-platform/blob/main/app/workers/tasks.py): `app/workers/tasks.py`
- [Parse, chunk, embed](https://github.com/harsh-up3131/enterprise-rag-platform/blob/main/app/services/ingestion/pipeline.py): `app/services/ingestion/pipeline.py`

### Grounded answering

- [Question API](https://github.com/harsh-up3131/enterprise-rag-platform/blob/main/app/api/routes/query.py): `app/api/routes/query.py`
- [Answer orchestration](https://github.com/harsh-up3131/enterprise-rag-platform/blob/main/app/services/query_service.py): `app/services/query_service.py`
- [Hybrid retrieval](https://github.com/harsh-up3131/enterprise-rag-platform/blob/main/app/services/retrieval/retriever.py): `app/services/retrieval/retriever.py`
- [Keyword search](https://github.com/harsh-up3131/enterprise-rag-platform/blob/main/app/services/retrieval/lexical.py): `app/services/retrieval/lexical.py`
- [Vector search](https://github.com/harsh-up3131/enterprise-rag-platform/blob/main/app/services/retrieval/dense.py): `app/services/retrieval/dense.py`
- [Rank fusion](https://github.com/harsh-up3131/enterprise-rag-platform/blob/main/app/services/retrieval/fusion.py): `app/services/retrieval/fusion.py`
- [Reranking](https://github.com/harsh-up3131/enterprise-rag-platform/blob/main/app/services/retrieval/reranker.py): `app/services/retrieval/reranker.py`
- [Prompt and LLM](https://github.com/harsh-up3131/enterprise-rag-platform/blob/main/app/services/generation/llm_client.py): `app/services/generation/llm_client.py`
- [Citation validation](https://github.com/harsh-up3131/enterprise-rag-platform/blob/main/app/services/generation/citation_validator.py): `app/services/generation/citation_validator.py`
- [Input and output checks](https://github.com/harsh-up3131/enterprise-rag-platform/blob/main/app/services/generation/guardrails.py): `app/services/generation/guardrails.py`

### Trust and evaluation

- [Retrieval trace records](https://github.com/harsh-up3131/enterprise-rag-platform/blob/main/app/models/trace.py): `app/models/trace.py`
- [Evaluation API](https://github.com/harsh-up3131/enterprise-rag-platform/blob/main/app/api/routes/eval.py): `app/api/routes/eval.py`
- [Evaluation runner](https://github.com/harsh-up3131/enterprise-rag-platform/blob/main/app/services/evaluation/runner.py): `app/services/evaluation/runner.py`
- [Security audit API](https://github.com/harsh-up3131/enterprise-rag-platform/blob/main/app/api/routes/security.py): `app/api/routes/security.py`
- [Tenant isolation check](https://github.com/harsh-up3131/enterprise-rag-platform/blob/main/app/services/security/tenant_isolation_check.py): `app/services/security/tenant_isolation_check.py`

### Other components

- **User**
- **PostgreSQL with pgvector**
- **Ollama LLM**

## Connections

- User → Web application: uses (evidence: `README.md`)
- Web application → Frontend API client: requests (evidence: `frontend/src/App.jsx`)
- Web application → Chat and evidence: shows
- Frontend API client → FastAPI application: calls API
- FastAPI application → Authentication routes: registers (evidence: `app/main.py`)
- FastAPI application → Document upload API: registers (evidence: `app/main.py`)
- FastAPI application → Question API: registers (evidence: `app/main.py`)
- Authentication routes → JWT security: issues tokens (evidence: `app/api/routes/auth.py`)
- Tenant request context → JWT security: decodes tokens (evidence: `app/core/deps.py`)
- Document upload API → Tenant request context: resolves identity (evidence: `app/api/routes/documents.py`)
- Document upload API → Object storage: stores uploads (evidence: `app/api/routes/documents.py`)
- Document upload API → Background ingestion task: queues indexing (evidence: `app/api/routes/documents.py`)
- Background ingestion task → Parse, chunk, embed: runs task (evidence: `app/workers/tasks.py`)
- Parse, chunk, embed → Object storage: reads files (evidence: `app/services/ingestion/pipeline.py`)
- Parse, chunk, embed → Relational and vector store: writes chunks (evidence: `app/services/ingestion/pipeline.py`)
- Relational and vector store → PostgreSQL with pgvector: connects (evidence: `app/database.py`)
- Question API → Tenant request context: resolves identity (evidence: `app/api/routes/query.py`)
- Question API → Answer orchestration: answers question (evidence: `app/api/routes/query.py`)
- Answer orchestration → Input and output checks: checks input (evidence: `app/services/query_service.py`)
- Answer orchestration → Hybrid retrieval: retrieves evidence (evidence: `app/services/query_service.py`)
- Hybrid retrieval → Keyword search: searches terms (evidence: `app/services/retrieval/retriever.py`)
- Hybrid retrieval → Vector search: searches vectors (evidence: `app/services/retrieval/retriever.py`)
- Hybrid retrieval → Rank fusion: merges ranks (evidence: `app/services/retrieval/retriever.py`)
- Hybrid retrieval → Reranking: reranks candidates (evidence: `app/services/retrieval/retriever.py`)
- Vector search → Relational and vector store: queries vectors (evidence: `app/services/retrieval/dense.py`)
- Keyword search → Relational and vector store: queries text (evidence: `app/services/retrieval/lexical.py`)
- Answer orchestration → Prompt and LLM: generates answer (evidence: `app/services/query_service.py`)
- Prompt and LLM → Ollama LLM: sends prompts
- Answer orchestration → Citation validation: validates sources (evidence: `app/services/query_service.py`)
- Answer orchestration → Input and output checks: checks output (evidence: `app/services/query_service.py`)
- Answer orchestration → Retrieval trace records: persists trace (evidence: `app/services/query_service.py`)
- Evaluation API → Evaluation runner: runs evaluation (evidence: `app/api/routes/eval.py`)
- Security audit API → Tenant isolation check: runs check (evidence: `app/api/routes/security.py`)
- Tenant isolation check → Hybrid retrieval: tests isolation
