# shreyashdarade/modular-rag-pipeline architecture

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

- Interactive diagram: https://gitdiagram.com/shreyashdarade/modular-rag-pipeline
- Repository: https://github.com/shreyashdarade/modular-rag-pipeline

## Overview

This is a modular, multilingual RAG service with REST/SSE and MCP interfaces, an optional Python SDK, and separate ingestion workers. The main flow is client request → API/application use case → retrieval or ingestion → answer/indexed corpus. Collections, parsers, models, queues, and runtime backends are configurable adapters. The graph includes documented evaluation and scaling capabilities; some subsystem links rely on README documentation or source-index references because their implementations were not excerpted.

Main entry points: [`src/core/container.py`](https://github.com/shreyashdarade/modular-rag-pipeline/blob/main/src/core/container.py) (Composition root), [`src/ingestion/service.py`](https://github.com/shreyashdarade/modular-rag-pipeline/blob/main/src/ingestion/service.py) (Ingestion pipeline), [`src/retrieval/pipeline.py`](https://github.com/shreyashdarade/modular-rag-pipeline/blob/main/src/retrieval/pipeline.py) (Retrieval pipeline), [`src/application/service.py`](https://github.com/shreyashdarade/modular-rag-pipeline/blob/main/src/application/service.py) (Use-case service)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["Interfaces"]
  node_api["REST and SSE API<br/>[server.py]"]
  node_sdk["Python SDK<br/>[client.py]"]
  node_mcp["MCP tools<br/>[server.py]"]
  node_cli["CLI and evaluation<br/>[app.py]"]
  node_evaluation["RAG evaluation<br/>[session.py]"]
end

subgraph group_app["Application"]
  node_appservice["Use-case service<br/>[service.py]"]
  node_config["Settings and specs<br/>[specs.py]"]
  node_container["Composition root<br/>[container.py]"]
end

subgraph group_ingest["Ingestion"]
  node_ingestservice["Ingestion pipeline<br/>[service.py]"]
  node_storage["Upload storage<br/>[storage.py]"]
  node_parsing["File parsing and OCR<br/>[registry.py]"]
  node_chunking["Chunking<br/>[recursive.py]"]
end

subgraph group_retrieve["Retrieval and chat"]
  node_retrieval["Retrieval pipeline<br/>[pipeline.py]"]
  node_hybrid["Hybrid search<br/>[hybrid.py]"]
  node_models["Model providers<br/>[registry.py]"]
  node_rerank["Model rerankers<br/>[rerankers.py]"]
  node_answer["Answer generation<br/>[answer.py]"]
  node_chat["Conversation service<br/>[service.py]"]
end

subgraph group_runtime["Runtime infrastructure"]
  node_jobs["Ingestion job queues<br/>[redis_streams.py]"]
  node_index[("Elasticsearch index<br/>[elastic.py]")]
  node_cache["Cache and runtime<br/>[cache.py]"]
end

node_client(("API client"))

node_client -->|"requests"| node_api
node_api -->|"builds services"| node_container
node_api -->|"routes use cases"| node_appservice
node_sdk -->|"uses shared cases"| node_appservice
node_mcp -->|"uses services"| node_container
node_cli -->|"uses configuration"| node_container
node_cli -->|"runs evaluation"| node_evaluation
node_container -->|"loads configuration"| node_config
node_container -->|"constructs pipeline"| node_ingestservice
node_container -->|"constructs pipeline"| node_retrieval
node_container -->|"constructs service"| node_chat
node_appservice -->|"coordinates ingestion"| node_ingestservice
node_appservice -->|"stores uploads"| node_storage
node_ingestservice -->|"selects parsers"| node_parsing
node_ingestservice -->|"chunks documents"| node_chunking
node_ingestservice -->|"embeds content"| node_models
node_ingestservice -->|"writes documents"| node_index
node_jobs -.->|"dispatches jobs"| node_ingestservice
node_retrieval -->|"retrieves candidates"| node_hybrid
node_retrieval -->|"caches results"| node_cache
node_hybrid -->|"searches indices"| node_index
node_hybrid -->|"embeds queries"| node_models
node_retrieval -.->|"reranks candidates"| node_rerank
node_answer -->|"gets evidence"| node_retrieval
node_answer -->|"generates answer"| node_models
node_chat -->|"answers turns"| node_answer
node_chat -.->|"stores conversations"| node_cache
node_evaluation -.->|"evaluates retrieval"| node_retrieval
node_evaluation -.->|"evaluates answers"| node_answer

click node_api "https://github.com/shreyashdarade/modular-rag-pipeline/blob/main/src/api/server.py"
click node_sdk "https://github.com/shreyashdarade/modular-rag-pipeline/blob/main/ai_rag_info/client.py"
click node_mcp "https://github.com/shreyashdarade/modular-rag-pipeline/blob/main/src/mcp_server/server.py"
click node_cli "https://github.com/shreyashdarade/modular-rag-pipeline/blob/main/src/cli/app.py"
click node_appservice "https://github.com/shreyashdarade/modular-rag-pipeline/blob/main/src/application/service.py"
click node_config "https://github.com/shreyashdarade/modular-rag-pipeline/blob/main/src/core/specs.py"
click node_container "https://github.com/shreyashdarade/modular-rag-pipeline/blob/main/src/core/container.py"
click node_ingestservice "https://github.com/shreyashdarade/modular-rag-pipeline/blob/main/src/ingestion/service.py"
click node_storage "https://github.com/shreyashdarade/modular-rag-pipeline/blob/main/src/ingestion/storage.py"
click node_parsing "https://github.com/shreyashdarade/modular-rag-pipeline/blob/main/src/parsing/registry.py"
click node_chunking "https://github.com/shreyashdarade/modular-rag-pipeline/blob/main/src/chunking/recursive.py"
click node_jobs "https://github.com/shreyashdarade/modular-rag-pipeline/blob/main/src/jobs/redis_streams.py"
click node_index "https://github.com/shreyashdarade/modular-rag-pipeline/blob/main/src/indexing/elastic.py"
click node_retrieval "https://github.com/shreyashdarade/modular-rag-pipeline/blob/main/src/retrieval/pipeline.py"
click node_hybrid "https://github.com/shreyashdarade/modular-rag-pipeline/blob/main/src/retrieval/hybrid.py"
click node_models "https://github.com/shreyashdarade/modular-rag-pipeline/blob/main/src/models/registry.py"
click node_rerank "https://github.com/shreyashdarade/modular-rag-pipeline/blob/main/src/models/rerankers.py"
click node_answer "https://github.com/shreyashdarade/modular-rag-pipeline/blob/main/src/chat/answer.py"
click node_chat "https://github.com/shreyashdarade/modular-rag-pipeline/blob/main/src/chat/service.py"
click node_cache "https://github.com/shreyashdarade/modular-rag-pipeline/blob/main/src/runtime/cache.py"
click node_evaluation "https://github.com/shreyashdarade/modular-rag-pipeline/blob/main/src/evaluation/session.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_api,node_sdk,node_mcp,node_cli,node_evaluation,node_client toneBlue
class node_appservice,node_config,node_container toneAmber
class node_ingestservice,node_storage,node_parsing,node_chunking toneMint
class node_retrieval,node_hybrid,node_models,node_rerank,node_answer,node_chat toneRose
class node_jobs,node_index,node_cache toneIndigo
```

## Components

### Interfaces

- [REST and SSE API](https://github.com/shreyashdarade/modular-rag-pipeline/blob/main/src/api/server.py): `src/api/server.py`
- [Python SDK](https://github.com/shreyashdarade/modular-rag-pipeline/blob/main/ai_rag_info/client.py): `ai_rag_info/client.py`
- [MCP tools](https://github.com/shreyashdarade/modular-rag-pipeline/blob/main/src/mcp_server/server.py): `src/mcp_server/server.py`
- [CLI and evaluation](https://github.com/shreyashdarade/modular-rag-pipeline/blob/main/src/cli/app.py): `src/cli/app.py`
- [RAG evaluation](https://github.com/shreyashdarade/modular-rag-pipeline/blob/main/src/evaluation/session.py): `src/evaluation/session.py`

### Application

- [Use-case service](https://github.com/shreyashdarade/modular-rag-pipeline/blob/main/src/application/service.py): `src/application/service.py`
- [Settings and specs](https://github.com/shreyashdarade/modular-rag-pipeline/blob/main/src/core/specs.py): `src/core/specs.py`
- [Composition root](https://github.com/shreyashdarade/modular-rag-pipeline/blob/main/src/core/container.py): `src/core/container.py`

### Ingestion

- [Ingestion pipeline](https://github.com/shreyashdarade/modular-rag-pipeline/blob/main/src/ingestion/service.py): `src/ingestion/service.py`
- [Upload storage](https://github.com/shreyashdarade/modular-rag-pipeline/blob/main/src/ingestion/storage.py): `src/ingestion/storage.py`
- [File parsing and OCR](https://github.com/shreyashdarade/modular-rag-pipeline/blob/main/src/parsing/registry.py): `src/parsing/registry.py`
- [Chunking](https://github.com/shreyashdarade/modular-rag-pipeline/blob/main/src/chunking/recursive.py): `src/chunking/recursive.py`

### Retrieval and chat

- [Retrieval pipeline](https://github.com/shreyashdarade/modular-rag-pipeline/blob/main/src/retrieval/pipeline.py): `src/retrieval/pipeline.py`
- [Hybrid search](https://github.com/shreyashdarade/modular-rag-pipeline/blob/main/src/retrieval/hybrid.py): `src/retrieval/hybrid.py`
- [Model providers](https://github.com/shreyashdarade/modular-rag-pipeline/blob/main/src/models/registry.py): `src/models/registry.py`
- [Model rerankers](https://github.com/shreyashdarade/modular-rag-pipeline/blob/main/src/models/rerankers.py): `src/models/rerankers.py`
- [Answer generation](https://github.com/shreyashdarade/modular-rag-pipeline/blob/main/src/chat/answer.py): `src/chat/answer.py`
- [Conversation service](https://github.com/shreyashdarade/modular-rag-pipeline/blob/main/src/chat/service.py): `src/chat/service.py`

### Runtime infrastructure

- [Ingestion job queues](https://github.com/shreyashdarade/modular-rag-pipeline/blob/main/src/jobs/redis_streams.py): `src/jobs/redis_streams.py`
- [Elasticsearch index](https://github.com/shreyashdarade/modular-rag-pipeline/blob/main/src/indexing/elastic.py): `src/indexing/elastic.py`
- [Cache and runtime](https://github.com/shreyashdarade/modular-rag-pipeline/blob/main/src/runtime/cache.py): `src/runtime/cache.py`

### Other components

- **API client**

## Connections

- API client → REST and SSE API: requests (evidence: `README.md`)
- REST and SSE API → Composition root: builds services (evidence: `src/api/server.py`)
- REST and SSE API → Use-case service: routes use cases (evidence: `README.md`)
- Python SDK → Use-case service: uses shared cases (evidence: `README.md`)
- MCP tools → Composition root: uses services (evidence: `src/mcp_server/server.py`)
- CLI and evaluation → Composition root: uses configuration (evidence: `src/cli/app.py`)
- CLI and evaluation → RAG evaluation: runs evaluation (evidence: `README.md`)
- Composition root → Settings and specs: loads configuration (evidence: `src/core/container.py`)
- Composition root → Ingestion pipeline: constructs pipeline (evidence: `src/core/container.py`)
- Composition root → Retrieval pipeline: constructs pipeline (evidence: `src/core/container.py`)
- Composition root → Conversation service: constructs service (evidence: `src/core/container.py`)
- Use-case service → Ingestion pipeline: coordinates ingestion (evidence: `src/application/service.py`)
- Use-case service → Upload storage: stores uploads (evidence: `src/application/service.py`)
- Ingestion pipeline → File parsing and OCR: selects parsers (evidence: `src/ingestion/service.py`)
- Ingestion pipeline → Chunking: chunks documents (evidence: `src/ingestion/service.py`)
- Ingestion pipeline → Model providers: embeds content (evidence: `src/ingestion/service.py`)
- Ingestion pipeline → Elasticsearch index: writes documents (evidence: `src/ingestion/service.py`)
- Ingestion job queues → Ingestion pipeline: dispatches jobs (evidence: `README.md`)
- Retrieval pipeline → Hybrid search: retrieves candidates (evidence: `src/retrieval/pipeline.py`)
- Retrieval pipeline → Cache and runtime: caches results (evidence: `src/retrieval/pipeline.py`)
- Hybrid search → Elasticsearch index: searches indices (evidence: `src/retrieval/hybrid.py`)
- Hybrid search → Model providers: embeds queries (evidence: `src/retrieval/hybrid.py`)
- Retrieval pipeline → Model rerankers: reranks candidates (evidence: `README.md`)
- Answer generation → Retrieval pipeline: gets evidence (evidence: `src/chat/answer.py`)
- Answer generation → Model providers: generates answer (evidence: `src/chat/answer.py`)
- Conversation service → Answer generation: answers turns (evidence: `src/chat/service.py`)
- Conversation service → Cache and runtime: stores conversations (evidence: `README.md`)
- RAG evaluation → Retrieval pipeline: evaluates retrieval (evidence: `README.md`)
- RAG evaluation → Answer generation: evaluates answers (evidence: `README.md`)
