# shivkhurana/omnirag architecture

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

- Interactive diagram: https://gitdiagram.com/shivkhurana/omnirag
- Repository: https://github.com/shivkhurana/omnirag

## Overview

OmniRAG is a full-stack workspace for registering users, indexing PDFs, and asking questions grounded in indexed content. Users authenticate in the React app, upload documents or submit questions through its API client, and the FastAPI routes handle authorization and domain work. PDF ingestion creates chunks and embeddings for persistent vector retrieval; chat retrieves relevant chunks and generates cited answers. MongoDB stores users and document metadata. The README documents the product capabilities; edges involving unsampled chat implementation are limited to indexed references.

Main entry points: [`backend/app/api/documents.py`](https://github.com/shivkhurana/omnirag/blob/main/backend/app/api/documents.py) (Document routes), [`frontend/src/lib/api.ts`](https://github.com/shivkhurana/omnirag/blob/main/frontend/src/lib/api.ts) (API client), [`backend/app/api/auth.py`](https://github.com/shivkhurana/omnirag/blob/main/backend/app/api/auth.py) (Auth routes), [`backend/app/api/chat.py`](https://github.com/shivkhurana/omnirag/blob/main/backend/app/api/chat.py) (Chat route)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_frontend["Workspace UI"]
  node_app["Session app<br/>[App.tsx]"]
  node_auth_ui["Auth screen<br/>[AuthScreen.tsx]"]
  node_workspace["Chat workspace<br/>[ChatWorkspace.tsx]"]
  node_client["API client<br/>[api.ts]"]
end

subgraph group_api["API workflows"]
  node_fastapi["FastAPI app<br/>[main.py]"]
  node_auth_route["Auth routes<br/>[auth.py]"]
  node_document_route["Document routes<br/>[documents.py]"]
  node_chat_route["Chat route<br/>[chat.py]"]
  node_schemas["API schemas<br/>[schemas.py]"]
end

subgraph group_identity["Identity and access"]
  node_access["User authorization<br/>[dependencies.py]"]
  node_security["Token security<br/>[security.py]"]
end

subgraph group_rag["Document intelligence"]
  node_rag_service["RAG service<br/>[rag.py]"]
  node_pdf_processing["PDF chunking<br/>[rag.py]"]
end

subgraph group_persistence["Persistence and services"]
  node_vector_store[("Chroma store<br/>[rag.py]")]
  node_openai["OpenAI models"]
  node_mongo[("MongoDB")]
  node_config["Runtime settings<br/>[config.py]"]
end

node_user(("Workspace user"))

node_user -->|"uses"| node_app
node_app -->|"renders"| node_auth_ui
node_app -->|"renders"| node_workspace
node_auth_ui -->|"authenticates via"| node_client
node_workspace -->|"requests data"| node_client
node_client -->|"calls auth endpoints"| node_auth_route
node_client -->|"calls document endpoints"| node_document_route
node_client -->|"calls chat endpoint"| node_chat_route
node_fastapi -->|"registers"| node_auth_route
node_fastapi -->|"registers"| node_document_route
node_fastapi -->|"registers"| node_chat_route
node_auth_route -->|"issues tokens"| node_security
node_auth_route -->|"reads and writes users"| node_mongo
node_access -->|"validates tokens"| node_security
node_access -->|"loads user"| node_mongo
node_document_route -->|"requires user"| node_access
node_chat_route -->|"uses authorization"| node_access
node_document_route -->|"ingests PDF"| node_rag_service
node_document_route -->|"stores metadata"| node_mongo
node_chat_route -->|"gets answers"| node_rag_service
node_rag_service -->|"extracts and chunks"| node_pdf_processing
node_rag_service -->|"indexes and searches"| node_vector_store
node_rag_service -->|"embeds and generates"| node_openai
node_security -->|"loads secrets"| node_config
node_vector_store -->|"loads storage path"| node_config
node_fastapi -->|"connects on startup"| node_mongo
node_auth_route -->|"validates requests"| node_schemas
node_document_route -->|"returns metadata"| node_schemas
node_chat_route -->|"uses chat models"| node_schemas

click node_app "https://github.com/shivkhurana/omnirag/blob/main/frontend/src/App.tsx"
click node_auth_ui "https://github.com/shivkhurana/omnirag/blob/main/frontend/src/components/AuthScreen.tsx"
click node_workspace "https://github.com/shivkhurana/omnirag/blob/main/frontend/src/components/ChatWorkspace.tsx"
click node_client "https://github.com/shivkhurana/omnirag/blob/main/frontend/src/lib/api.ts"
click node_fastapi "https://github.com/shivkhurana/omnirag/blob/main/backend/app/main.py"
click node_auth_route "https://github.com/shivkhurana/omnirag/blob/main/backend/app/api/auth.py"
click node_document_route "https://github.com/shivkhurana/omnirag/blob/main/backend/app/api/documents.py"
click node_chat_route "https://github.com/shivkhurana/omnirag/blob/main/backend/app/api/chat.py"
click node_schemas "https://github.com/shivkhurana/omnirag/blob/main/backend/app/models/schemas.py"
click node_access "https://github.com/shivkhurana/omnirag/blob/main/backend/app/api/dependencies.py"
click node_security "https://github.com/shivkhurana/omnirag/blob/main/backend/app/core/security.py"
click node_rag_service "https://github.com/shivkhurana/omnirag/blob/main/backend/app/services/rag.py"
click node_pdf_processing "https://github.com/shivkhurana/omnirag/blob/main/backend/app/services/rag.py"
click node_vector_store "https://github.com/shivkhurana/omnirag/blob/main/backend/app/services/rag.py"
click node_config "https://github.com/shivkhurana/omnirag/blob/main/backend/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_app,node_auth_ui,node_workspace,node_client,node_user toneBlue
class node_fastapi,node_auth_route,node_document_route,node_chat_route,node_schemas toneAmber
class node_access,node_security toneMint
class node_rag_service,node_pdf_processing toneRose
class node_vector_store,node_openai,node_mongo,node_config toneIndigo
```

## Components

### Workspace UI

- [Session app](https://github.com/shivkhurana/omnirag/blob/main/frontend/src/App.tsx): `frontend/src/App.tsx`
- [Auth screen](https://github.com/shivkhurana/omnirag/blob/main/frontend/src/components/AuthScreen.tsx): `frontend/src/components/AuthScreen.tsx`
- [Chat workspace](https://github.com/shivkhurana/omnirag/blob/main/frontend/src/components/ChatWorkspace.tsx): `frontend/src/components/ChatWorkspace.tsx`
- [API client](https://github.com/shivkhurana/omnirag/blob/main/frontend/src/lib/api.ts): `frontend/src/lib/api.ts`

### API workflows

- [FastAPI app](https://github.com/shivkhurana/omnirag/blob/main/backend/app/main.py): `backend/app/main.py`
- [Auth routes](https://github.com/shivkhurana/omnirag/blob/main/backend/app/api/auth.py): `backend/app/api/auth.py`
- [Document routes](https://github.com/shivkhurana/omnirag/blob/main/backend/app/api/documents.py): `backend/app/api/documents.py`
- [Chat route](https://github.com/shivkhurana/omnirag/blob/main/backend/app/api/chat.py): `backend/app/api/chat.py`
- [API schemas](https://github.com/shivkhurana/omnirag/blob/main/backend/app/models/schemas.py): `backend/app/models/schemas.py`

### Identity and access

- [User authorization](https://github.com/shivkhurana/omnirag/blob/main/backend/app/api/dependencies.py): `backend/app/api/dependencies.py`
- [Token security](https://github.com/shivkhurana/omnirag/blob/main/backend/app/core/security.py): `backend/app/core/security.py`

### Document intelligence

- [RAG service](https://github.com/shivkhurana/omnirag/blob/main/backend/app/services/rag.py): `backend/app/services/rag.py`
- [PDF chunking](https://github.com/shivkhurana/omnirag/blob/main/backend/app/services/rag.py): `backend/app/services/rag.py`

### Persistence and services

- [Chroma store](https://github.com/shivkhurana/omnirag/blob/main/backend/app/services/rag.py): `backend/app/services/rag.py`
- **OpenAI models**
- **MongoDB**
- [Runtime settings](https://github.com/shivkhurana/omnirag/blob/main/backend/app/core/config.py): `backend/app/core/config.py`

### Other components

- **Workspace user**

## Connections

- Workspace user → Session app: uses (evidence: `frontend/src/App.tsx`)
- Session app → Auth screen: renders (evidence: `frontend/src/App.tsx`)
- Session app → Chat workspace: renders (evidence: `frontend/src/App.tsx`)
- Auth screen → API client: authenticates via (evidence: `frontend/src/components/AuthScreen.tsx`)
- Chat workspace → API client: requests data (evidence: `frontend/src/components/ChatWorkspace.tsx`)
- API client → Auth routes: calls auth endpoints (evidence: `README.md`)
- API client → Document routes: calls document endpoints (evidence: `README.md`)
- API client → Chat route: calls chat endpoint (evidence: `README.md`)
- FastAPI app → Auth routes: registers (evidence: `backend/app/main.py`)
- FastAPI app → Document routes: registers (evidence: `backend/app/main.py`)
- FastAPI app → Chat route: registers (evidence: `backend/app/main.py`)
- Auth routes → Token security: issues tokens (evidence: `backend/app/api/auth.py`)
- Auth routes → MongoDB: reads and writes users (evidence: `backend/app/api/auth.py`)
- User authorization → Token security: validates tokens (evidence: `backend/app/api/dependencies.py`)
- User authorization → MongoDB: loads user (evidence: `backend/app/api/dependencies.py`)
- Document routes → User authorization: requires user (evidence: `backend/app/api/documents.py`)
- Chat route → User authorization: uses authorization (evidence: `backend/app/api/chat.py`)
- Document routes → RAG service: ingests PDF (evidence: `backend/app/api/documents.py`)
- Document routes → MongoDB: stores metadata (evidence: `backend/app/api/documents.py`)
- Chat route → RAG service: gets answers (evidence: `backend/app/api/chat.py`)
- RAG service → PDF chunking: extracts and chunks (evidence: `backend/app/services/rag.py`)
- RAG service → Chroma store: indexes and searches (evidence: `backend/app/services/rag.py`)
- RAG service → OpenAI models: embeds and generates (evidence: `backend/app/services/rag.py`)
- Token security → Runtime settings: loads secrets (evidence: `backend/app/core/security.py`)
- Chroma store → Runtime settings: loads storage path (evidence: `backend/app/services/rag.py`)
- FastAPI app → MongoDB: connects on startup (evidence: `backend/app/main.py`)
- Auth routes → API schemas: validates requests (evidence: `backend/app/api/auth.py`)
- Document routes → API schemas: returns metadata (evidence: `backend/app/api/documents.py`)
- Chat route → API schemas: uses chat models (evidence: `backend/app/api/chat.py`)
