# devloperdevesh/enterpriserag-ai architecture

> Architecture diagram of the GitHub repository devloperdevesh/enterpriserag-ai, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-12). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/devloperdevesh/enterpriserag-ai
- Repository: https://github.com/devloperdevesh/enterpriserag-ai

## Overview

EnterpriseRAG-AI combines a React control-center frontend with a FastAPI backend for tenant-aware RAG, document ingestion, query streaming, and operational visibility. The principal workflow is authenticated document upload and indexing, followed by query embedding, vector retrieval, streamed LLM response, and per-user history. The graph preserves the README’s security, observability, and reliability branches. Sampled files establish the shown calls; unsampled integrations and dashboard-to-API wiring are omitted or marked unverified.

Main entry points: [`app/main.py`](https://github.com/devloperdevesh/enterpriserag-ai/blob/main/app/main.py) (FastAPI application), [`app/api/routes/rag.py`](https://github.com/devloperdevesh/enterpriserag-ai/blob/main/app/api/routes/rag.py) (RAG query and streaming), [`app/api/routes/document.py`](https://github.com/devloperdevesh/enterpriserag-ai/blob/main/app/api/routes/document.py) (Document ingestion), [`app/api/routes/auth.py`](https://github.com/devloperdevesh/enterpriserag-ai/blob/main/app/api/routes/auth.py) (Authentication routes)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["Application and security"]
  node_api["FastAPI application<br/>[main.py]"]
  node_authroute["Authentication routes<br/>[auth.py]"]
  node_authservice["Authentication service<br/>[auth_service.py]"]
  node_security["JWT and password security<br/>[security.py]"]
  node_identity["Request identity<br/>[dependencies.py]"]
  node_tenant["Tenant administration<br/>[tenants.py]"]
end

subgraph group_rag["Retrieval and answers"]
  node_documents["Document ingestion<br/>[document.py]"]
  node_chunking["Chunking and embeddings<br/>[chunker.py]"]
  node_embedding["Embedding generation<br/>[embeddings.py]"]
  node_vector[("Vector retrieval<br/>[vector_store.py]")]
  node_ragroute["RAG query and streaming<br/>[rag.py]"]
  node_llm["LLM generation<br/>[llm.py]"]
  node_rerank["Reranking pipeline<br/>[rag_service.py]"]
end

subgraph group_state["Persistence and history"]
  node_queryhistory["Query history<br/>[query_history.py]"]
  node_redisclient[("Redis client<br/>[redis_client.py]")]
  node_dbsession[("Database sessions<br/>[session.py]")]
  node_models[("User tenant documents<br/>[user.py]")]
end

subgraph group_ops["Operations and reliability"]
  node_observability["Tracing and telemetry<br/>[rag_tracing.py]"]
  node_ratelimit["Rate limiting<br/>[rate_limit.py]"]
  node_worker["Background workers<br/>[celery_worker.py]"]
end

subgraph group_ui["Control center"]
  node_web["Web application<br/>[AppRoutes.tsx]"]
  node_chatui["RAG chat interface<br/>[QueryRAG.tsx]"]
  node_chatservice["Chat API service<br/>[chatService.ts]"]
  node_client["HTTP API client<br/>[client.ts]"]
  node_historyui["Query history panel"]
  node_historyservice["History API service<br/>[historyService.ts]"]
  node_dashboard["Operational dashboard<br/>[Analytics.tsx]"]
end

node_user(("Enterprise user"))

node_user -->|"uses"| node_web
node_web -.->|"requests"| node_api
node_web -.->|"authenticates"| node_authroute
node_api -->|"registers"| node_authroute
node_api -->|"registers"| node_documents
node_api -->|"registers"| node_ragroute
node_api -->|"registers"| node_tenant
node_authroute -->|"authenticates"| node_authservice
node_authservice -->|"verifies credentials"| node_security
node_authroute -->|"hashes passwords"| node_security
node_api -->|"protects routes"| node_identity
node_identity -->|"decodes token"| node_security
node_documents -->|"chunks documents"| node_chunking
node_documents -->|"generates embeddings"| node_embedding
node_documents -->|"indexes vectors"| node_vector
node_ragroute -->|"embeds query"| node_embedding
node_ragroute -->|"searches vectors"| node_vector
node_ragroute -->|"generates stream"| node_llm
node_ragroute -->|"records query"| node_queryhistory
node_ragroute -->|"reads history"| node_queryhistory
node_queryhistory -->|"uses Redis"| node_redisclient
node_authservice -->|"queries users"| node_models
node_documents -->|"uses session"| node_dbsession
node_documents -->|"stores documents"| node_models
node_api -->|"configures tracing"| node_observability
node_api -->|"initializes limiter"| node_ratelimit
node_chatui -->|"submits queries"| node_chatservice
node_chatservice -->|"sends requests"| node_client
node_historyui -->|"loads history"| node_historyservice
node_historyservice -->|"sends requests"| node_client
node_dashboard -.->|"fetches telemetry"| node_api
node_ragroute -.->|"uses pipeline"| node_rerank
node_api -.->|"dispatches jobs"| node_worker

click node_web "https://github.com/devloperdevesh/enterpriserag-ai/blob/main/frontend/src/routes/AppRoutes.tsx"
click node_api "https://github.com/devloperdevesh/enterpriserag-ai/blob/main/app/main.py"
click node_authroute "https://github.com/devloperdevesh/enterpriserag-ai/blob/main/app/api/routes/auth.py"
click node_authservice "https://github.com/devloperdevesh/enterpriserag-ai/blob/main/app/services/auth_service.py"
click node_security "https://github.com/devloperdevesh/enterpriserag-ai/blob/main/app/core/security.py"
click node_identity "https://github.com/devloperdevesh/enterpriserag-ai/blob/main/app/core/dependencies.py"
click node_tenant "https://github.com/devloperdevesh/enterpriserag-ai/blob/main/app/api/routes/tenants.py"
click node_documents "https://github.com/devloperdevesh/enterpriserag-ai/blob/main/app/api/routes/document.py"
click node_chunking "https://github.com/devloperdevesh/enterpriserag-ai/blob/main/app/rag/chunker.py"
click node_embedding "https://github.com/devloperdevesh/enterpriserag-ai/blob/main/app/rag/embeddings.py"
click node_vector "https://github.com/devloperdevesh/enterpriserag-ai/blob/main/app/rag/vector_store.py"
click node_ragroute "https://github.com/devloperdevesh/enterpriserag-ai/blob/main/app/api/routes/rag.py"
click node_llm "https://github.com/devloperdevesh/enterpriserag-ai/blob/main/app/rag/llm.py"
click node_rerank "https://github.com/devloperdevesh/enterpriserag-ai/blob/main/app/rag/rag_service.py"
click node_queryhistory "https://github.com/devloperdevesh/enterpriserag-ai/blob/main/app/rag/query_history.py"
click node_redisclient "https://github.com/devloperdevesh/enterpriserag-ai/blob/main/app/core/redis_client.py"
click node_dbsession "https://github.com/devloperdevesh/enterpriserag-ai/blob/main/app/db/session.py"
click node_models "https://github.com/devloperdevesh/enterpriserag-ai/blob/main/app/models/user.py"
click node_observability "https://github.com/devloperdevesh/enterpriserag-ai/blob/main/app/observability/rag_tracing.py"
click node_ratelimit "https://github.com/devloperdevesh/enterpriserag-ai/blob/main/app/reliability/rate_limit.py"
click node_worker "https://github.com/devloperdevesh/enterpriserag-ai/blob/main/app/workers/celery_worker.py"
click node_chatui "https://github.com/devloperdevesh/enterpriserag-ai/blob/main/frontend/src/rag/QueryRAG.tsx"
click node_chatservice "https://github.com/devloperdevesh/enterpriserag-ai/blob/main/frontend/src/services/chatService.ts"
click node_client "https://github.com/devloperdevesh/enterpriserag-ai/blob/main/frontend/src/api/client.ts"
click node_historyui "https://github.com/devloperdevesh/enterpriserag-ai/blob/main/frontend/src/rag/QueryHistoryPanel.tsx"
click node_historyservice "https://github.com/devloperdevesh/enterpriserag-ai/blob/main/frontend/src/services/historyService.ts"
click node_dashboard "https://github.com/devloperdevesh/enterpriserag-ai/blob/main/frontend/src/app/pages/Analytics.tsx"

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_api,node_authroute,node_authservice,node_security,node_identity,node_tenant,node_user toneBlue
class node_documents,node_chunking,node_embedding,node_vector,node_ragroute,node_llm,node_rerank toneAmber
class node_queryhistory,node_redisclient,node_dbsession,node_models toneMint
class node_observability,node_ratelimit,node_worker toneRose
class node_web,node_chatui,node_chatservice,node_client,node_historyui,node_historyservice,node_dashboard toneIndigo
```

## Components

### Application and security

- [FastAPI application](https://github.com/devloperdevesh/enterpriserag-ai/blob/main/app/main.py): `app/main.py`
- [Authentication routes](https://github.com/devloperdevesh/enterpriserag-ai/blob/main/app/api/routes/auth.py): `app/api/routes/auth.py`
- [Authentication service](https://github.com/devloperdevesh/enterpriserag-ai/blob/main/app/services/auth_service.py): `app/services/auth_service.py`
- [JWT and password security](https://github.com/devloperdevesh/enterpriserag-ai/blob/main/app/core/security.py): `app/core/security.py`
- [Request identity](https://github.com/devloperdevesh/enterpriserag-ai/blob/main/app/core/dependencies.py): `app/core/dependencies.py`
- [Tenant administration](https://github.com/devloperdevesh/enterpriserag-ai/blob/main/app/api/routes/tenants.py): `app/api/routes/tenants.py`

### Retrieval and answers

- [Document ingestion](https://github.com/devloperdevesh/enterpriserag-ai/blob/main/app/api/routes/document.py): `app/api/routes/document.py`
- [Chunking and embeddings](https://github.com/devloperdevesh/enterpriserag-ai/blob/main/app/rag/chunker.py): `app/rag/chunker.py`
- [Embedding generation](https://github.com/devloperdevesh/enterpriserag-ai/blob/main/app/rag/embeddings.py): `app/rag/embeddings.py`
- [Vector retrieval](https://github.com/devloperdevesh/enterpriserag-ai/blob/main/app/rag/vector_store.py): `app/rag/vector_store.py`
- [RAG query and streaming](https://github.com/devloperdevesh/enterpriserag-ai/blob/main/app/api/routes/rag.py): `app/api/routes/rag.py`
- [LLM generation](https://github.com/devloperdevesh/enterpriserag-ai/blob/main/app/rag/llm.py): `app/rag/llm.py`
- [Reranking pipeline](https://github.com/devloperdevesh/enterpriserag-ai/blob/main/app/rag/rag_service.py): `app/rag/rag_service.py`

### Persistence and history

- [Query history](https://github.com/devloperdevesh/enterpriserag-ai/blob/main/app/rag/query_history.py): `app/rag/query_history.py`
- [Redis client](https://github.com/devloperdevesh/enterpriserag-ai/blob/main/app/core/redis_client.py): `app/core/redis_client.py`
- [Database sessions](https://github.com/devloperdevesh/enterpriserag-ai/blob/main/app/db/session.py): `app/db/session.py`
- [User tenant documents](https://github.com/devloperdevesh/enterpriserag-ai/blob/main/app/models/user.py): `app/models/user.py`

### Operations and reliability

- [Tracing and telemetry](https://github.com/devloperdevesh/enterpriserag-ai/blob/main/app/observability/rag_tracing.py): `app/observability/rag_tracing.py`
- [Rate limiting](https://github.com/devloperdevesh/enterpriserag-ai/blob/main/app/reliability/rate_limit.py): `app/reliability/rate_limit.py`
- [Background workers](https://github.com/devloperdevesh/enterpriserag-ai/blob/main/app/workers/celery_worker.py): `app/workers/celery_worker.py`

### Control center

- [Web application](https://github.com/devloperdevesh/enterpriserag-ai/blob/main/frontend/src/routes/AppRoutes.tsx): `frontend/src/routes/AppRoutes.tsx`
- [RAG chat interface](https://github.com/devloperdevesh/enterpriserag-ai/blob/main/frontend/src/rag/QueryRAG.tsx): `frontend/src/rag/QueryRAG.tsx`
- [Chat API service](https://github.com/devloperdevesh/enterpriserag-ai/blob/main/frontend/src/services/chatService.ts): `frontend/src/services/chatService.ts`
- [HTTP API client](https://github.com/devloperdevesh/enterpriserag-ai/blob/main/frontend/src/api/client.ts): `frontend/src/api/client.ts`
- [Query history panel](https://github.com/devloperdevesh/enterpriserag-ai/blob/main/frontend/src/rag/QueryHistoryPanel.tsx): `frontend/src/rag/QueryHistoryPanel.tsx`
- [History API service](https://github.com/devloperdevesh/enterpriserag-ai/blob/main/frontend/src/services/historyService.ts): `frontend/src/services/historyService.ts`
- [Operational dashboard](https://github.com/devloperdevesh/enterpriserag-ai/blob/main/frontend/src/app/pages/Analytics.tsx): `frontend/src/app/pages/Analytics.tsx`

### Other components

- **Enterprise user**

## Connections

- Enterprise user → Web application: uses (evidence: `README.md`)
- Web application → FastAPI application: requests
- Web application → Authentication routes: authenticates
- FastAPI application → Authentication routes: registers (evidence: `app/main.py`)
- FastAPI application → Document ingestion: registers (evidence: `app/main.py`)
- FastAPI application → RAG query and streaming: registers (evidence: `app/main.py`)
- FastAPI application → Tenant administration: registers (evidence: `app/main.py`)
- Authentication routes → Authentication service: authenticates (evidence: `app/api/routes/auth.py`)
- Authentication service → JWT and password security: verifies credentials (evidence: `app/services/auth_service.py`)
- Authentication routes → JWT and password security: hashes passwords (evidence: `app/api/routes/auth.py`)
- FastAPI application → Request identity: protects routes (evidence: `app/main.py`)
- Request identity → JWT and password security: decodes token (evidence: `app/core/dependencies.py`)
- Document ingestion → Chunking and embeddings: chunks documents (evidence: `app/api/routes/document.py`)
- Document ingestion → Embedding generation: generates embeddings (evidence: `app/api/routes/document.py`)
- Document ingestion → Vector retrieval: indexes vectors (evidence: `app/api/routes/document.py`)
- RAG query and streaming → Embedding generation: embeds query (evidence: `app/api/routes/rag.py`)
- RAG query and streaming → Vector retrieval: searches vectors (evidence: `app/api/routes/rag.py`)
- RAG query and streaming → LLM generation: generates stream (evidence: `app/api/routes/rag.py`)
- RAG query and streaming → Query history: records query (evidence: `app/api/routes/rag.py`)
- RAG query and streaming → Query history: reads history (evidence: `app/api/routes/rag.py`)
- Query history → Redis client: uses Redis (evidence: `app/rag/query_history.py`)
- Authentication service → User tenant documents: queries users (evidence: `app/services/auth_service.py`)
- Document ingestion → Database sessions: uses session (evidence: `app/api/routes/document.py`)
- Document ingestion → User tenant documents: stores documents (evidence: `app/api/routes/document.py`)
- FastAPI application → Tracing and telemetry: configures tracing (evidence: `app/main.py`)
- FastAPI application → Rate limiting: initializes limiter (evidence: `app/main.py`)
- RAG chat interface → Chat API service: submits queries (evidence: `frontend/src/rag/QueryRAG.tsx`)
- Chat API service → HTTP API client: sends requests (evidence: `frontend/src/services/chatService.ts`)
- Query history panel → History API service: loads history (evidence: `frontend/src/rag/QueryHistoryPanel.tsx`)
- History API service → HTTP API client: sends requests (evidence: `frontend/src/services/historyService.ts`)
- Operational dashboard → FastAPI application: fetches telemetry
- RAG query and streaming → Reranking pipeline: uses pipeline
- FastAPI application → Background workers: dispatches jobs
