# beshoy1612/multi_model_rag architecture

> Architecture diagram of the GitHub repository beshoy1612/multi_model_rag, 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/beshoy1612/multi_model_rag
- Repository: https://github.com/beshoy1612/multi_model_rag

## Overview

Multi_Model_RAG is a FastAPI retrieval-augmented generation service. Its apparent workflow accepts project files, extracts and chunks document content, stores project/chunk records, indexes chunks for semantic and keyword retrieval, then combines and reranks search results. The sampled NLP controller implements hybrid search; generation and image-analysis interfaces exist, but their use in a user-facing answer flow is not shown. Route-to-controller execution and some ingestion/storage connections are not visible in the excerpts, so those links are omitted or marked unverified.

Main entry points: [`Src/main.py`](https://github.com/beshoy1612/multi_model_rag/blob/master/Src/main.py) (FastAPI app), [`Src/Routes`](https://github.com/beshoy1612/multi_model_rag/tree/master/Src/Routes) (API routes), [`Src/Controllers/NLP_Controller.py`](https://github.com/beshoy1612/multi_model_rag/blob/master/Src/Controllers/NLP_Controller.py) (Hybrid search), [`Src/models/Chunk_model.py`](https://github.com/beshoy1612/multi_model_rag/blob/master/Src/models/Chunk_model.py) (Chunk records)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_api["API and orchestration"]
  node_app["FastAPI app<br/>[main.py]"]
  node_routes["API routes"]
  node_nlp_route["NLP endpoints<br/>[NLP.py]"]
end

subgraph group_ingest["Project and ingestion"]
  node_data_ctrl["Upload validation<br/>[Data_controller.py]"]
  node_process_ctrl["Document processing"]
  node_project_ctrl["Project files"]
end

subgraph group_retrieval["Hybrid retrieval"]
  node_nlp_ctrl["Hybrid search<br/>[NLP_Controller.py]"]
end

subgraph group_providers["Provider integrations"]
  node_llm_factory["LLM factory"]
  node_llm_providers["Cohere / Gemini"]
  node_llm_interface["LLM interface<br/>[LLMinterface.py]"]
  node_vector_factory["Vector DB factory"]
  node_qdrant["Qdrant adapter<br/>[Qdrantdb.py]"]
  node_keyword_factory["Keyword factory"]
  node_bm25["BM25 search<br/>[BM25Provider.py]"]
end

subgraph group_persistence["Persistence"]
  node_chunk_model["Chunk records<br/>[Chunk_model.py]"]
  node_project_model["Project records<br/>[Project_model.py]"]
  node_asset_model["Asset records<br/>[Asset_model.py]"]
  node_db_schemes["ORM schemas"]
  node_postgres[("PostgreSQL")]
end

node_user(("API client"))

node_user -->|"sends requests"| node_app
node_app -->|"registers routes"| node_routes
node_routes -.->|"uses upload logic"| node_data_ctrl
node_routes -.->|"uses processing"| node_process_ctrl
node_routes -.->|"references projects"| node_project_model
node_routes -.->|"references assets"| node_asset_model
node_nlp_route -.->|"uses search logic"| node_nlp_ctrl
node_app -->|"registers router"| node_nlp_route
node_process_ctrl -->|"resolves file path"| node_project_ctrl
node_nlp_ctrl -->|"loads ranked chunks"| node_chunk_model
node_nlp_ctrl -.->|"uses embedding client"| node_llm_factory
node_nlp_ctrl -.->|"uses vector client"| node_vector_factory
node_nlp_ctrl -.->|"uses keyword client"| node_keyword_factory
node_app -->|"creates model"| node_chunk_model
node_app -->|"creates providers"| node_llm_factory
node_app -->|"creates provider"| node_vector_factory
node_app -->|"creates provider"| node_keyword_factory
node_llm_factory -->|"selects provider"| node_llm_providers
node_llm_providers -->|"implements contract"| node_llm_interface
node_vector_factory -->|"selects adapter"| node_qdrant
node_keyword_factory -->|"selects provider"| node_bm25
node_chunk_model -->|"queries chunks"| node_db_schemes
node_project_model -->|"uses project schema"| node_db_schemes
node_asset_model -->|"uses asset schema"| node_db_schemes
node_chunk_model -.->|"reads and writes"| node_postgres
node_project_model -.->|"reads and writes"| node_postgres
node_asset_model -.->|"reads and writes"| node_postgres

click node_app "https://github.com/beshoy1612/multi_model_rag/blob/master/Src/main.py"
click node_routes "https://github.com/beshoy1612/multi_model_rag/tree/master/Src/Routes"
click node_data_ctrl "https://github.com/beshoy1612/multi_model_rag/blob/master/Src/Controllers/Data_controller.py"
click node_process_ctrl "https://github.com/beshoy1612/multi_model_rag/blob/master/Src/Controllers/Process_Controller.py"
click node_project_ctrl "https://github.com/beshoy1612/multi_model_rag/blob/master/Src/Controllers/Project_Controller.py"
click node_nlp_route "https://github.com/beshoy1612/multi_model_rag/blob/master/Src/Routes/NLP.py"
click node_nlp_ctrl "https://github.com/beshoy1612/multi_model_rag/blob/master/Src/Controllers/NLP_Controller.py"
click node_chunk_model "https://github.com/beshoy1612/multi_model_rag/blob/master/Src/models/Chunk_model.py"
click node_project_model "https://github.com/beshoy1612/multi_model_rag/blob/master/Src/models/Project_model.py"
click node_asset_model "https://github.com/beshoy1612/multi_model_rag/blob/master/Src/models/Asset_model.py"
click node_db_schemes "https://github.com/beshoy1612/multi_model_rag/tree/master/Src/models/db_schemes/schemes"
click node_llm_factory "https://github.com/beshoy1612/multi_model_rag/blob/master/Src/stores/LLM/LLMProviderFactory.py"
click node_llm_providers "https://github.com/beshoy1612/multi_model_rag/tree/master/Src/stores/LLM/Providers"
click node_llm_interface "https://github.com/beshoy1612/multi_model_rag/blob/master/Src/stores/LLM/LLMinterface.py"
click node_vector_factory "https://github.com/beshoy1612/multi_model_rag/blob/master/Src/stores/Vectordb/Vectordb_Provider_Factory.py"
click node_qdrant "https://github.com/beshoy1612/multi_model_rag/blob/master/Src/stores/Vectordb/Providers/Qdrantdb.py"
click node_keyword_factory "https://github.com/beshoy1612/multi_model_rag/blob/master/Src/stores/LLM/KeywordSearch/KeywordSearch_Provider_Factory.py"
click node_bm25 "https://github.com/beshoy1612/multi_model_rag/blob/master/Src/stores/LLM/KeywordSearch/Provider/BM25Provider.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_routes,node_nlp_route,node_user toneBlue
class node_data_ctrl,node_process_ctrl,node_project_ctrl toneAmber
class node_nlp_ctrl toneMint
class node_llm_factory,node_llm_providers,node_llm_interface,node_vector_factory,node_qdrant,node_keyword_factory,node_bm25 toneRose
class node_chunk_model,node_project_model,node_asset_model,node_db_schemes,node_postgres toneIndigo
```

## Components

### API and orchestration

- [FastAPI app](https://github.com/beshoy1612/multi_model_rag/blob/master/Src/main.py): `Src/main.py`
- [API routes](https://github.com/beshoy1612/multi_model_rag/tree/master/Src/Routes): `Src/Routes`
- [NLP endpoints](https://github.com/beshoy1612/multi_model_rag/blob/master/Src/Routes/NLP.py): `Src/Routes/NLP.py`

### Project and ingestion

- [Upload validation](https://github.com/beshoy1612/multi_model_rag/blob/master/Src/Controllers/Data_controller.py): `Src/Controllers/Data_controller.py`
- [Document processing](https://github.com/beshoy1612/multi_model_rag/blob/master/Src/Controllers/Process_Controller.py): `Src/Controllers/Process_Controller.py`
- [Project files](https://github.com/beshoy1612/multi_model_rag/blob/master/Src/Controllers/Project_Controller.py): `Src/Controllers/Project_Controller.py`

### Hybrid retrieval

- [Hybrid search](https://github.com/beshoy1612/multi_model_rag/blob/master/Src/Controllers/NLP_Controller.py): `Src/Controllers/NLP_Controller.py`

### Provider integrations

- [LLM factory](https://github.com/beshoy1612/multi_model_rag/blob/master/Src/stores/LLM/LLMProviderFactory.py): `Src/stores/LLM/LLMProviderFactory.py`
- [Cohere / Gemini](https://github.com/beshoy1612/multi_model_rag/tree/master/Src/stores/LLM/Providers): `Src/stores/LLM/Providers`
- [LLM interface](https://github.com/beshoy1612/multi_model_rag/blob/master/Src/stores/LLM/LLMinterface.py): `Src/stores/LLM/LLMinterface.py`
- [Vector DB factory](https://github.com/beshoy1612/multi_model_rag/blob/master/Src/stores/Vectordb/Vectordb_Provider_Factory.py): `Src/stores/Vectordb/Vectordb_Provider_Factory.py`
- [Qdrant adapter](https://github.com/beshoy1612/multi_model_rag/blob/master/Src/stores/Vectordb/Providers/Qdrantdb.py): `Src/stores/Vectordb/Providers/Qdrantdb.py`
- [Keyword factory](https://github.com/beshoy1612/multi_model_rag/blob/master/Src/stores/LLM/KeywordSearch/KeywordSearch_Provider_Factory.py): `Src/stores/LLM/KeywordSearch/KeywordSearch_Provider_Factory.py`
- [BM25 search](https://github.com/beshoy1612/multi_model_rag/blob/master/Src/stores/LLM/KeywordSearch/Provider/BM25Provider.py): `Src/stores/LLM/KeywordSearch/Provider/BM25Provider.py`

### Persistence

- [Chunk records](https://github.com/beshoy1612/multi_model_rag/blob/master/Src/models/Chunk_model.py): `Src/models/Chunk_model.py`
- [Project records](https://github.com/beshoy1612/multi_model_rag/blob/master/Src/models/Project_model.py): `Src/models/Project_model.py`
- [Asset records](https://github.com/beshoy1612/multi_model_rag/blob/master/Src/models/Asset_model.py): `Src/models/Asset_model.py`
- [ORM schemas](https://github.com/beshoy1612/multi_model_rag/tree/master/Src/models/db_schemes/schemes): `Src/models/db_schemes/schemes`
- **PostgreSQL**

### Other components

- **API client**

## Connections

- API client → FastAPI app: sends requests
- FastAPI app → API routes: registers routes (evidence: `Src/main.py`)
- API routes → Upload validation: uses upload logic (evidence: `Src/Routes/data.py`)
- API routes → Document processing: uses processing (evidence: `Src/Routes/data.py`)
- API routes → Project records: references projects (evidence: `Src/Routes/NLP.py`)
- API routes → Asset records: references assets (evidence: `Src/Routes/data.py`)
- NLP endpoints → Hybrid search: uses search logic (evidence: `Src/Routes/NLP.py`)
- FastAPI app → NLP endpoints: registers router (evidence: `Src/main.py`)
- Document processing → Project files: resolves file path (evidence: `Src/Controllers/Process_Controller.py`)
- Hybrid search → Chunk records: loads ranked chunks (evidence: `Src/Controllers/NLP_Controller.py`)
- Hybrid search → LLM factory: uses embedding client
- Hybrid search → Vector DB factory: uses vector client
- Hybrid search → Keyword factory: uses keyword client
- FastAPI app → Chunk records: creates model (evidence: `Src/main.py`)
- FastAPI app → LLM factory: creates providers (evidence: `Src/main.py`)
- FastAPI app → Vector DB factory: creates provider (evidence: `Src/main.py`)
- FastAPI app → Keyword factory: creates provider (evidence: `Src/main.py`)
- LLM factory → Cohere / Gemini: selects provider (evidence: `Src/stores/LLM/LLMProviderFactory.py`)
- Cohere / Gemini → LLM interface: implements contract (evidence: `Src/stores/LLM/Providers/CohereProvider.py`)
- Vector DB factory → Qdrant adapter: selects adapter (evidence: `Src/stores/Vectordb/Vectordb_Provider_Factory.py`)
- Keyword factory → BM25 search: selects provider (evidence: `Src/stores/LLM/KeywordSearch/KeywordSearch_Provider_Factory.py`)
- Chunk records → ORM schemas: queries chunks (evidence: `Src/models/Chunk_model.py`)
- Project records → ORM schemas: uses project schema (evidence: `Src/models/Project_model.py`)
- Asset records → ORM schemas: uses asset schema (evidence: `Src/models/Asset_model.py`)
- Chunk records → PostgreSQL: reads and writes
- Project records → PostgreSQL: reads and writes
- Asset records → PostgreSQL: reads and writes
