# alharthalhajhussein/mini-rag-app architecture

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

- Interactive diagram: https://gitdiagram.com/alharthalhajhussein/mini-rag-app
- Repository: https://github.com/alharthalhajhussein/mini-rag-app

## Overview

Mini-RAG-App is a FastAPI service for project-scoped document question answering. Users upload PDF or text files, which are processed into chunks; chunks can then be embedded and indexed, searched, or used to generate RAG answers. The graph preserves project/data management, NLP indexing and retrieval, configurable model and vector-store backends, and persistence. Some route and provider implementations were not excerpted, so their connections are limited to relationships supported by the README or SOURCE INDEX; dashed links indicate unverified wiring.

Main entry points: [`src/routes/data.py`](https://github.com/alharthalhajhussein/mini-rag-app/blob/main/src/routes/data.py) (Data routes), [`src/controllers/nlp_controller.py`](https://github.com/alharthalhajhussein/mini-rag-app/blob/main/src/controllers/nlp_controller.py) (RAG orchestration), [`src/routes/nlp.py`](https://github.com/alharthalhajhussein/mini-rag-app/blob/main/src/routes/nlp.py) (NLP routes), [`src/main.py`](https://github.com/alharthalhajhussein/mini-rag-app/blob/main/src/main.py) (FastAPI app)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_api["API and orchestration"]
  node_app["FastAPI app<br/>[main.py]"]
  node_data_routes["Data routes<br/>[data.py]"]
  node_nlp_routes["NLP routes<br/>[nlp.py]"]
end

subgraph group_documents["Document processing"]
  node_project_ctrl["Project files"]
  node_data_ctrl["Upload validation<br/>[data_controller.py]"]
  node_process_ctrl["File chunking"]
end

subgraph group_rag["Retrieval and generation"]
  node_nlp_ctrl["RAG orchestration<br/>[nlp_controller.py]"]
  node_templates["Prompt templates<br/>[template_parser.py]"]
  node_llm_factory["LLM provider factory"]
  node_llm_backends["LLM backends"]
end

subgraph group_storage["Persistence and backends"]
  node_project_model["Project records<br/>[project_model.py]"]
  node_chunk_model["Chunk records<br/>[chunk_model.py]"]
  node_asset_model["Asset records<br/>[asset_model.py]"]
  node_db_schemes["Database schemas"]
  node_vector_factory["Vector store factory"]
  node_vector_backends["Vector store backends"]
  node_pgvector["Pgvector provider"]
  node_qdrant["Qdrant provider"]
end

node_user(("API user"))
node_postgres[("PostgreSQL")]
node_vector_service[("Vector database")]
node_llm_service["Model service"]

node_user -->|"uploads files"| node_data_routes
node_user -->|"queries API"| node_nlp_routes
node_app -->|"registers routes"| node_data_routes
node_app -->|"registers routes"| node_nlp_routes
node_data_routes -->|"validates uploads"| node_data_ctrl
node_data_routes -.->|"processes files"| node_process_ctrl
node_data_routes -->|"manages projects"| node_project_model
node_data_routes -->|"stores chunks"| node_chunk_model
node_data_ctrl -->|"gets project path"| node_project_ctrl
node_process_ctrl -->|"gets project path"| node_project_ctrl
node_process_ctrl -.->|"creates chunks"| node_chunk_model
node_project_model -.->|"persists records"| node_postgres
node_chunk_model -.->|"persists chunks"| node_postgres
node_nlp_routes -->|"loads project"| node_project_model
node_nlp_routes -->|"loads chunks"| node_chunk_model
node_nlp_routes -->|"dispatches RAG work"| node_nlp_ctrl
node_nlp_ctrl -->|"indexes and searches"| node_vector_service
node_nlp_ctrl -->|"embeds and generates"| node_llm_service
node_nlp_ctrl -->|"builds prompts"| node_templates
node_nlp_ctrl -->|"uses chunk schemas"| node_db_schemes
node_app -->|"creates clients"| node_llm_factory
node_app -->|"creates client"| node_vector_factory
node_llm_factory -->|"selects provider"| node_llm_backends
node_vector_factory -.->|"selects provider"| node_vector_backends
node_vector_backends -.->|"includes backend"| node_pgvector
node_vector_backends -.->|"includes backend"| node_qdrant
node_pgvector -.->|"stores vectors"| node_postgres
node_qdrant -.->|"stores vectors"| node_vector_service
node_llm_backends -.->|"calls model APIs"| node_llm_service

click node_app "https://github.com/alharthalhajhussein/mini-rag-app/blob/main/src/main.py"
click node_data_routes "https://github.com/alharthalhajhussein/mini-rag-app/blob/main/src/routes/data.py"
click node_nlp_routes "https://github.com/alharthalhajhussein/mini-rag-app/blob/main/src/routes/nlp.py"
click node_project_ctrl "https://github.com/alharthalhajhussein/mini-rag-app/blob/main/src/controllers/project_controller.py"
click node_data_ctrl "https://github.com/alharthalhajhussein/mini-rag-app/blob/main/src/controllers/data_controller.py"
click node_process_ctrl "https://github.com/alharthalhajhussein/mini-rag-app/blob/main/src/controllers/process_controller.py"
click node_project_model "https://github.com/alharthalhajhussein/mini-rag-app/blob/main/src/models/project_model.py"
click node_chunk_model "https://github.com/alharthalhajhussein/mini-rag-app/blob/main/src/models/chunk_model.py"
click node_asset_model "https://github.com/alharthalhajhussein/mini-rag-app/blob/main/src/models/asset_model.py"
click node_db_schemes "https://github.com/alharthalhajhussein/mini-rag-app/tree/main/src/models/db_schemes/minirag/schemes"
click node_nlp_ctrl "https://github.com/alharthalhajhussein/mini-rag-app/blob/main/src/controllers/nlp_controller.py"
click node_templates "https://github.com/alharthalhajhussein/mini-rag-app/blob/main/src/stores/llm/templates/template_parser.py"
click node_llm_factory "https://github.com/alharthalhajhussein/mini-rag-app/blob/main/src/stores/llm/llm_provider_factory.py"
click node_llm_backends "https://github.com/alharthalhajhussein/mini-rag-app/tree/main/src/stores/llm/providers"
click node_vector_factory "https://github.com/alharthalhajhussein/mini-rag-app/blob/main/src/stores/vector_db/vector_db_provider_factory.py"
click node_vector_backends "https://github.com/alharthalhajhussein/mini-rag-app/tree/main/src/stores/vector_db/providers"
click node_pgvector "https://github.com/alharthalhajhussein/mini-rag-app/blob/main/src/stores/vector_db/providers/pgvector_db_provider.py"
click node_qdrant "https://github.com/alharthalhajhussein/mini-rag-app/blob/main/src/stores/vector_db/providers/qdrant_db_provider.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_data_routes,node_nlp_routes,node_user toneBlue
class node_project_ctrl,node_data_ctrl,node_process_ctrl,node_postgres,node_vector_service toneAmber
class node_nlp_ctrl,node_templates,node_llm_factory,node_llm_backends toneMint
class node_project_model,node_chunk_model,node_asset_model,node_db_schemes,node_vector_factory,node_vector_backends,node_pgvector,node_qdrant toneRose
class node_llm_service toneIndigo
```

## Components

### API and orchestration

- [FastAPI app](https://github.com/alharthalhajhussein/mini-rag-app/blob/main/src/main.py): `src/main.py`
- [Data routes](https://github.com/alharthalhajhussein/mini-rag-app/blob/main/src/routes/data.py): `src/routes/data.py`
- [NLP routes](https://github.com/alharthalhajhussein/mini-rag-app/blob/main/src/routes/nlp.py): `src/routes/nlp.py`

### Document processing

- [Project files](https://github.com/alharthalhajhussein/mini-rag-app/blob/main/src/controllers/project_controller.py): `src/controllers/project_controller.py`
- [Upload validation](https://github.com/alharthalhajhussein/mini-rag-app/blob/main/src/controllers/data_controller.py): `src/controllers/data_controller.py`
- [File chunking](https://github.com/alharthalhajhussein/mini-rag-app/blob/main/src/controllers/process_controller.py): `src/controllers/process_controller.py`

### Retrieval and generation

- [RAG orchestration](https://github.com/alharthalhajhussein/mini-rag-app/blob/main/src/controllers/nlp_controller.py): `src/controllers/nlp_controller.py`
- [Prompt templates](https://github.com/alharthalhajhussein/mini-rag-app/blob/main/src/stores/llm/templates/template_parser.py): `src/stores/llm/templates/template_parser.py`
- [LLM provider factory](https://github.com/alharthalhajhussein/mini-rag-app/blob/main/src/stores/llm/llm_provider_factory.py): `src/stores/llm/llm_provider_factory.py`
- [LLM backends](https://github.com/alharthalhajhussein/mini-rag-app/tree/main/src/stores/llm/providers): `src/stores/llm/providers`

### Persistence and backends

- [Project records](https://github.com/alharthalhajhussein/mini-rag-app/blob/main/src/models/project_model.py): `src/models/project_model.py`
- [Chunk records](https://github.com/alharthalhajhussein/mini-rag-app/blob/main/src/models/chunk_model.py): `src/models/chunk_model.py`
- [Asset records](https://github.com/alharthalhajhussein/mini-rag-app/blob/main/src/models/asset_model.py): `src/models/asset_model.py`
- [Database schemas](https://github.com/alharthalhajhussein/mini-rag-app/tree/main/src/models/db_schemes/minirag/schemes): `src/models/db_schemes/minirag/schemes`
- [Vector store factory](https://github.com/alharthalhajhussein/mini-rag-app/blob/main/src/stores/vector_db/vector_db_provider_factory.py): `src/stores/vector_db/vector_db_provider_factory.py`
- [Vector store backends](https://github.com/alharthalhajhussein/mini-rag-app/tree/main/src/stores/vector_db/providers): `src/stores/vector_db/providers`
- [Pgvector provider](https://github.com/alharthalhajhussein/mini-rag-app/blob/main/src/stores/vector_db/providers/pgvector_db_provider.py): `src/stores/vector_db/providers/pgvector_db_provider.py`
- [Qdrant provider](https://github.com/alharthalhajhussein/mini-rag-app/blob/main/src/stores/vector_db/providers/qdrant_db_provider.py): `src/stores/vector_db/providers/qdrant_db_provider.py`

### Other components

- **API user**
- **PostgreSQL**
- **Vector database**
- **Model service**

## Connections

- API user → Data routes: uploads files (evidence: `src/routes/data.py`)
- API user → NLP routes: queries API (evidence: `src/routes/nlp.py`)
- FastAPI app → Data routes: registers routes (evidence: `src/main.py`)
- FastAPI app → NLP routes: registers routes (evidence: `src/main.py`)
- Data routes → Upload validation: validates uploads (evidence: `src/routes/data.py`)
- Data routes → File chunking: processes files
- Data routes → Project records: manages projects (evidence: `src/routes/data.py`)
- Data routes → Chunk records: stores chunks (evidence: `src/routes/data.py`)
- Upload validation → Project files: gets project path (evidence: `src/controllers/data_controller.py`)
- File chunking → Project files: gets project path (evidence: `src/controllers/process_controller.py`)
- File chunking → Chunk records: creates chunks
- Project records → PostgreSQL: persists records
- Chunk records → PostgreSQL: persists chunks
- NLP routes → Project records: loads project (evidence: `src/routes/nlp.py`)
- NLP routes → Chunk records: loads chunks (evidence: `src/routes/nlp.py`)
- NLP routes → RAG orchestration: dispatches RAG work (evidence: `src/routes/nlp.py`)
- RAG orchestration → Vector database: indexes and searches (evidence: `src/controllers/nlp_controller.py`)
- RAG orchestration → Model service: embeds and generates (evidence: `src/controllers/nlp_controller.py`)
- RAG orchestration → Prompt templates: builds prompts (evidence: `src/controllers/nlp_controller.py`)
- RAG orchestration → Database schemas: uses chunk schemas (evidence: `src/controllers/nlp_controller.py`)
- FastAPI app → LLM provider factory: creates clients (evidence: `src/main.py`)
- FastAPI app → Vector store factory: creates client (evidence: `src/main.py`)
- LLM provider factory → LLM backends: selects provider (evidence: `src/stores/llm/llm_provider_factory.py`)
- Vector store factory → Vector store backends: selects provider
- Vector store backends → Pgvector provider: includes backend
- Vector store backends → Qdrant provider: includes backend
- Pgvector provider → PostgreSQL: stores vectors
- Qdrant provider → Vector database: stores vectors
- LLM backends → Model service: calls model APIs
