# prav3106/omrag architecture

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

- Interactive diagram: https://gitdiagram.com/prav3106/omrag
- Repository: https://github.com/prav3106/omrag

## Overview

This is an offline multimodal RAG application: users upload documents, images, or audio, then ask questions grounded in the unified index. Uploads pass through MIME-based extraction, chunking, embedding, and persistence; queries pass through hybrid retrieval and local answer generation with source citations. The React workspace also exposes document management, pipeline inspection, dashboard metrics, and dependency status. The README documents the complete product stages; some parser and router internals were not excerpted, so those links rely on its architecture/API descriptions.

Main entry points: [`frontend/src/lib/api.js`](https://github.com/prav3106/omrag/blob/master/frontend/src/lib/api.js) (API client), [`backend/app/service.py`](https://github.com/prav3106/omrag/blob/master/backend/app/service.py) (Ingest orchestration), [`frontend/src/App.jsx`](https://github.com/prav3106/omrag/blob/master/frontend/src/App.jsx) (App shell), [`backend/app/retrieval/pipeline.py`](https://github.com/prav3106/omrag/blob/master/backend/app/retrieval/pipeline.py) (Retrieval pipeline)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_frontend["React workspace"]
  node_app["App shell<br/>[App.jsx]"]
  node_chat["Chat workspace<br/>[ChatWorkspace.jsx]"]
  node_knowledge["Knowledge base<br/>[KnowledgeBase.jsx]"]
  node_dashboard["Dashboard<br/>[Dashboard.jsx]"]
  node_processor["Processor lab<br/>[ProcessorLab.jsx]"]
  node_statusui["System status<br/>[SystemStatus.jsx]"]
  node_ui_components["UI components<br/>[Primitives.jsx]"]
  node_api_client["API client<br/>[api.js]"]
end

subgraph group_api["API layer"]
  node_api_app["FastAPI app<br/>[main.py]"]
  node_ingest_route["Ingest endpoint<br/>[ingest.py]"]
  node_query_route["Query endpoint<br/>[query.py]"]
  node_index_routes["Index endpoints<br/>[index.py]"]
  node_status_route["Status endpoint<br/>[status.py]"]
  node_models["Shared schemas<br/>[models.py]"]
end

subgraph group_ingestion["Ingestion pipeline"]
  node_service["Ingest orchestration<br/>[service.py]"]
  node_dispatch["MIME dispatch<br/>[router.py]"]
  node_loaders["Format loaders"]
  node_chunker["Chunking<br/>[chunker.py]"]
  node_text_encoder["Text embeddings<br/>[text_encoder.py]"]
  node_image_encoder["Image embeddings<br/>[image_encoder.py]"]
  node_vision["Image descriptions<br/>[vision_describe.py]"]
end

subgraph group_query["Retrieval and answers"]
  node_retrieval["Retrieval pipeline<br/>[pipeline.py]"]
  node_bm25["BM25 fusion<br/>[bm25.py]"]
  node_mmr["MMR diversity<br/>[mmr.py]"]
  node_reranker["Cross-encoder rerank<br/>[reranker.py]"]
  node_prompt["Grounded prompts<br/>[prompt_builder.py]"]
  node_generator["Local answer generation<br/>[ollama_client.py]"]
end

subgraph group_storage["Index and state"]
  node_qdrant[("Qdrant vectors<br/>[qdrant_store.py]")]
  node_sqlite[("SQLite registry<br/>[sqlite_registry.py]")]
  node_dedup["Content deduplication<br/>[dedup.py]"]
end

node_user(("User"))
node_ollama{{"Ollama"}}

node_user -->|"uses"| node_app
node_app -->|"routes to"| node_chat
node_app -->|"routes to"| node_knowledge
node_app -->|"routes to"| node_dashboard
node_app -->|"routes to"| node_processor
node_app -->|"routes to"| node_statusui
node_app -->|"loads stats"| node_api_client
node_chat -->|"queries"| node_api_client
node_knowledge -->|"manages uploads"| node_api_client
node_dashboard -->|"requests metrics"| node_api_client
node_processor -->|"inspects pipeline"| node_api_client
node_statusui -->|"checks health"| node_api_client
node_api_client -->|"posts uploads"| node_ingest_route
node_api_client -->|"posts queries"| node_query_route
node_api_client -->|"requests index"| node_index_routes
node_api_client -->|"requests status"| node_status_route
node_app -.->|"renders controls"| node_ui_components
node_api_app -->|"registers routes"| node_ingest_route
node_api_app -->|"registers routes"| node_query_route
node_api_app -->|"registers routes"| node_index_routes
node_api_app -->|"registers routes"| node_status_route
node_ingest_route -->|"calls ingestion"| node_service
node_query_route -->|"calls retrieval"| node_retrieval
node_query_route -->|"requests answer"| node_generator
node_query_route -->|"logs query"| node_sqlite
node_service -->|"routes files"| node_dispatch
node_dispatch -->|"dispatches formats"| node_loaders
node_service -->|"chunks content"| node_chunker
node_service -->|"embeds text"| node_text_encoder
node_service -->|"embeds images"| node_image_encoder
node_service -->|"describes images"| node_vision
node_service -->|"identifies content"| node_dedup
node_service -->|"writes vectors"| node_qdrant
node_service -->|"commits registry"| node_sqlite
node_retrieval -->|"encodes query"| node_text_encoder
node_retrieval -->|"encodes visual query"| node_image_encoder
node_retrieval -->|"searches vectors"| node_qdrant
node_retrieval -->|"hydrates chunks"| node_sqlite
node_retrieval -->|"fuses sparse scores"| node_bm25
node_retrieval -->|"diversifies shortlist"| node_mmr
node_retrieval -->|"reranks candidates"| node_reranker
node_generator -->|"builds prompt"| node_prompt
node_generator -->|"generates locally"| node_ollama
node_generator -->|"returns cited answer"| node_query_route
node_index_routes -.->|"manages vectors"| node_qdrant
node_index_routes -.->|"manages documents"| node_sqlite
node_status_route -.->|"checks health"| node_qdrant
node_status_route -.->|"checks health"| node_sqlite

click node_app "https://github.com/prav3106/omrag/blob/master/frontend/src/App.jsx"
click node_chat "https://github.com/prav3106/omrag/blob/master/frontend/src/pages/ChatWorkspace.jsx"
click node_knowledge "https://github.com/prav3106/omrag/blob/master/frontend/src/pages/KnowledgeBase.jsx"
click node_dashboard "https://github.com/prav3106/omrag/blob/master/frontend/src/pages/Dashboard.jsx"
click node_processor "https://github.com/prav3106/omrag/blob/master/frontend/src/pages/ProcessorLab.jsx"
click node_statusui "https://github.com/prav3106/omrag/blob/master/frontend/src/pages/SystemStatus.jsx"
click node_ui_components "https://github.com/prav3106/omrag/blob/master/frontend/src/components/Primitives.jsx"
click node_api_client "https://github.com/prav3106/omrag/blob/master/frontend/src/lib/api.js"
click node_api_app "https://github.com/prav3106/omrag/blob/master/backend/app/main.py"
click node_ingest_route "https://github.com/prav3106/omrag/blob/master/backend/app/routers/ingest.py"
click node_query_route "https://github.com/prav3106/omrag/blob/master/backend/app/routers/query.py"
click node_index_routes "https://github.com/prav3106/omrag/blob/master/backend/app/routers/index.py"
click node_status_route "https://github.com/prav3106/omrag/blob/master/backend/app/routers/status.py"
click node_service "https://github.com/prav3106/omrag/blob/master/backend/app/service.py"
click node_dispatch "https://github.com/prav3106/omrag/blob/master/backend/app/ingest/router.py"
click node_loaders "https://github.com/prav3106/omrag/tree/master/backend/app/ingest"
click node_chunker "https://github.com/prav3106/omrag/blob/master/backend/app/ingest/chunker.py"
click node_text_encoder "https://github.com/prav3106/omrag/blob/master/backend/app/embeddings/text_encoder.py"
click node_image_encoder "https://github.com/prav3106/omrag/blob/master/backend/app/embeddings/image_encoder.py"
click node_vision "https://github.com/prav3106/omrag/blob/master/backend/app/embeddings/vision_describe.py"
click node_retrieval "https://github.com/prav3106/omrag/blob/master/backend/app/retrieval/pipeline.py"
click node_bm25 "https://github.com/prav3106/omrag/blob/master/backend/app/retrieval/bm25.py"
click node_mmr "https://github.com/prav3106/omrag/blob/master/backend/app/retrieval/mmr.py"
click node_reranker "https://github.com/prav3106/omrag/blob/master/backend/app/retrieval/reranker.py"
click node_prompt "https://github.com/prav3106/omrag/blob/master/backend/app/generation/prompt_builder.py"
click node_generator "https://github.com/prav3106/omrag/blob/master/backend/app/generation/ollama_client.py"
click node_qdrant "https://github.com/prav3106/omrag/blob/master/backend/app/store/qdrant_store.py"
click node_sqlite "https://github.com/prav3106/omrag/blob/master/backend/app/store/sqlite_registry.py"
click node_dedup "https://github.com/prav3106/omrag/blob/master/backend/app/store/dedup.py"
click node_models "https://github.com/prav3106/omrag/blob/master/backend/app/models.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_chat,node_knowledge,node_dashboard,node_processor,node_statusui,node_ui_components,node_api_client,node_user toneBlue
class node_api_app,node_ingest_route,node_query_route,node_index_routes,node_status_route,node_models toneAmber
class node_service,node_dispatch,node_loaders,node_chunker,node_text_encoder,node_image_encoder,node_vision toneMint
class node_retrieval,node_bm25,node_mmr,node_reranker,node_prompt,node_generator toneRose
class node_qdrant,node_sqlite,node_dedup,node_ollama toneIndigo
```

## Components

### React workspace

- [App shell](https://github.com/prav3106/omrag/blob/master/frontend/src/App.jsx): `frontend/src/App.jsx`
- [Chat workspace](https://github.com/prav3106/omrag/blob/master/frontend/src/pages/ChatWorkspace.jsx): `frontend/src/pages/ChatWorkspace.jsx`
- [Knowledge base](https://github.com/prav3106/omrag/blob/master/frontend/src/pages/KnowledgeBase.jsx): `frontend/src/pages/KnowledgeBase.jsx`
- [Dashboard](https://github.com/prav3106/omrag/blob/master/frontend/src/pages/Dashboard.jsx): `frontend/src/pages/Dashboard.jsx`
- [Processor lab](https://github.com/prav3106/omrag/blob/master/frontend/src/pages/ProcessorLab.jsx): `frontend/src/pages/ProcessorLab.jsx`
- [System status](https://github.com/prav3106/omrag/blob/master/frontend/src/pages/SystemStatus.jsx): `frontend/src/pages/SystemStatus.jsx`
- [UI components](https://github.com/prav3106/omrag/blob/master/frontend/src/components/Primitives.jsx): `frontend/src/components/Primitives.jsx`
- [API client](https://github.com/prav3106/omrag/blob/master/frontend/src/lib/api.js): `frontend/src/lib/api.js`

### API layer

- [FastAPI app](https://github.com/prav3106/omrag/blob/master/backend/app/main.py): `backend/app/main.py`
- [Ingest endpoint](https://github.com/prav3106/omrag/blob/master/backend/app/routers/ingest.py): `backend/app/routers/ingest.py`
- [Query endpoint](https://github.com/prav3106/omrag/blob/master/backend/app/routers/query.py): `backend/app/routers/query.py`
- [Index endpoints](https://github.com/prav3106/omrag/blob/master/backend/app/routers/index.py): `backend/app/routers/index.py`
- [Status endpoint](https://github.com/prav3106/omrag/blob/master/backend/app/routers/status.py): `backend/app/routers/status.py`
- [Shared schemas](https://github.com/prav3106/omrag/blob/master/backend/app/models.py): `backend/app/models.py`

### Ingestion pipeline

- [Ingest orchestration](https://github.com/prav3106/omrag/blob/master/backend/app/service.py): `backend/app/service.py`
- [MIME dispatch](https://github.com/prav3106/omrag/blob/master/backend/app/ingest/router.py): `backend/app/ingest/router.py`
- [Format loaders](https://github.com/prav3106/omrag/tree/master/backend/app/ingest): `backend/app/ingest`
- [Chunking](https://github.com/prav3106/omrag/blob/master/backend/app/ingest/chunker.py): `backend/app/ingest/chunker.py`
- [Text embeddings](https://github.com/prav3106/omrag/blob/master/backend/app/embeddings/text_encoder.py): `backend/app/embeddings/text_encoder.py`
- [Image embeddings](https://github.com/prav3106/omrag/blob/master/backend/app/embeddings/image_encoder.py): `backend/app/embeddings/image_encoder.py`
- [Image descriptions](https://github.com/prav3106/omrag/blob/master/backend/app/embeddings/vision_describe.py): `backend/app/embeddings/vision_describe.py`

### Retrieval and answers

- [Retrieval pipeline](https://github.com/prav3106/omrag/blob/master/backend/app/retrieval/pipeline.py): `backend/app/retrieval/pipeline.py`
- [BM25 fusion](https://github.com/prav3106/omrag/blob/master/backend/app/retrieval/bm25.py): `backend/app/retrieval/bm25.py`
- [MMR diversity](https://github.com/prav3106/omrag/blob/master/backend/app/retrieval/mmr.py): `backend/app/retrieval/mmr.py`
- [Cross-encoder rerank](https://github.com/prav3106/omrag/blob/master/backend/app/retrieval/reranker.py): `backend/app/retrieval/reranker.py`
- [Grounded prompts](https://github.com/prav3106/omrag/blob/master/backend/app/generation/prompt_builder.py): `backend/app/generation/prompt_builder.py`
- [Local answer generation](https://github.com/prav3106/omrag/blob/master/backend/app/generation/ollama_client.py): `backend/app/generation/ollama_client.py`

### Index and state

- [Qdrant vectors](https://github.com/prav3106/omrag/blob/master/backend/app/store/qdrant_store.py): `backend/app/store/qdrant_store.py`
- [SQLite registry](https://github.com/prav3106/omrag/blob/master/backend/app/store/sqlite_registry.py): `backend/app/store/sqlite_registry.py`
- [Content deduplication](https://github.com/prav3106/omrag/blob/master/backend/app/store/dedup.py): `backend/app/store/dedup.py`

### Other components

- **User**
- **Ollama**

## Connections

- User → App shell: uses (evidence: `README.md`)
- App shell → Chat workspace: routes to (evidence: `frontend/src/App.jsx`)
- App shell → Knowledge base: routes to (evidence: `frontend/src/App.jsx`)
- App shell → Dashboard: routes to (evidence: `frontend/src/App.jsx`)
- App shell → Processor lab: routes to (evidence: `frontend/src/App.jsx`)
- App shell → System status: routes to (evidence: `frontend/src/App.jsx`)
- App shell → API client: loads stats (evidence: `frontend/src/App.jsx`)
- Chat workspace → API client: queries (evidence: `frontend/src/pages/ChatWorkspace.jsx`)
- Knowledge base → API client: manages uploads (evidence: `frontend/src/pages/KnowledgeBase.jsx`)
- Dashboard → API client: requests metrics (evidence: `frontend/src/pages/Dashboard.jsx`)
- Processor lab → API client: inspects pipeline (evidence: `frontend/src/pages/ProcessorLab.jsx`)
- System status → API client: checks health (evidence: `frontend/src/pages/SystemStatus.jsx`)
- API client → Ingest endpoint: posts uploads (evidence: `frontend/src/lib/api.js`)
- API client → Query endpoint: posts queries (evidence: `frontend/src/lib/api.js`)
- API client → Index endpoints: requests index (evidence: `frontend/src/lib/api.js`)
- API client → Status endpoint: requests status (evidence: `frontend/src/lib/api.js`)
- App shell → UI components: renders controls
- FastAPI app → Ingest endpoint: registers routes (evidence: `backend/app/main.py`)
- FastAPI app → Query endpoint: registers routes (evidence: `backend/app/main.py`)
- FastAPI app → Index endpoints: registers routes (evidence: `backend/app/main.py`)
- FastAPI app → Status endpoint: registers routes (evidence: `backend/app/main.py`)
- Ingest endpoint → Ingest orchestration: calls ingestion (evidence: `backend/app/routers/ingest.py`)
- Query endpoint → Retrieval pipeline: calls retrieval (evidence: `backend/app/routers/query.py`)
- Query endpoint → Local answer generation: requests answer (evidence: `backend/app/routers/query.py`)
- Query endpoint → SQLite registry: logs query (evidence: `backend/app/routers/query.py`)
- Ingest orchestration → MIME dispatch: routes files (evidence: `backend/app/service.py`)
- MIME dispatch → Format loaders: dispatches formats (evidence: `backend/app/ingest/router.py`)
- Ingest orchestration → Chunking: chunks content (evidence: `backend/app/service.py`)
- Ingest orchestration → Text embeddings: embeds text (evidence: `backend/app/service.py`)
- Ingest orchestration → Image embeddings: embeds images (evidence: `backend/app/service.py`)
- Ingest orchestration → Image descriptions: describes images (evidence: `backend/app/service.py`)
- Ingest orchestration → Content deduplication: identifies content (evidence: `backend/app/service.py`)
- Ingest orchestration → Qdrant vectors: writes vectors (evidence: `backend/app/service.py`)
- Ingest orchestration → SQLite registry: commits registry (evidence: `backend/app/service.py`)
- Retrieval pipeline → Text embeddings: encodes query (evidence: `backend/app/retrieval/pipeline.py`)
- Retrieval pipeline → Image embeddings: encodes visual query (evidence: `backend/app/retrieval/pipeline.py`)
- Retrieval pipeline → Qdrant vectors: searches vectors (evidence: `backend/app/retrieval/pipeline.py`)
- Retrieval pipeline → SQLite registry: hydrates chunks (evidence: `backend/app/retrieval/pipeline.py`)
- Retrieval pipeline → BM25 fusion: fuses sparse scores (evidence: `backend/app/retrieval/pipeline.py`)
- Retrieval pipeline → MMR diversity: diversifies shortlist (evidence: `backend/app/retrieval/pipeline.py`)
- Retrieval pipeline → Cross-encoder rerank: reranks candidates (evidence: `backend/app/retrieval/pipeline.py`)
- Local answer generation → Grounded prompts: builds prompt (evidence: `backend/app/generation/ollama_client.py`)
- Local answer generation → Ollama: generates locally (evidence: `README.md`)
- Local answer generation → Query endpoint: returns cited answer (evidence: `backend/app/routers/query.py`)
- Index endpoints → Qdrant vectors: manages vectors
- Index endpoints → SQLite registry: manages documents
- Status endpoint → Qdrant vectors: checks health
- Status endpoint → SQLite registry: checks health
