# a7medrajab1/mini-rag architecture

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

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

## Overview

This is a FastAPI backend for project-scoped file ingestion and text chunking. Its main workflow accepts an upload, validates and stores the file while recording an asset, then processes selected or project-wide files into ordered chunks. The graph also preserves health checking and the settings, controller, persistence-model, and schema layers. Source excerpts show route-to-controller/model calls and processing behavior; persistence-model internals were not excerpted, so their database connections are shown only as unverified.

Main entry points: [`src/routes/data.py`](https://github.com/a7medrajab1/mini-rag/blob/main/src/routes/data.py) (Data Routes), [`src/controllers/ProjectController.py`](https://github.com/a7medrajab1/mini-rag/blob/main/src/controllers/ProjectController.py) (Project Files), [`src/main.py`](https://github.com/a7medrajab1/mini-rag/blob/main/src/main.py) (FastAPI App), [`src/controllers/DataController.py`](https://github.com/a7medrajab1/mini-rag/blob/main/src/controllers/DataController.py) (Upload Validation)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_api["HTTP API"]
  node_app["FastAPI App<br/>[main.py]"]
  node_health["Health Route<br/>[base.py]"]
  node_data_routes["Data Routes<br/>[data.py]"]
  node_process_request["Process Request<br/>[data.py]"]
  node_settings["Settings<br/>[config.py]"]
end

subgraph group_ingest["File Ingestion"]
  node_data_controller["Upload Validation<br/>[DataController.py]"]
  node_project_controller["Project Files"]
  node_base_controller["Controller Base<br/>[BaseController.py]"]
end

subgraph group_processing["Text Processing"]
  node_process_controller["File Processing"]
  node_processing_types["File Types<br/>[ProcessingEnum.py]"]
end

subgraph group_persistence["Persistence"]
  node_asset_model["Asset Records<br/>[AssetModel.py]"]
  node_project_model["Project Records<br/>[ProjectModel.py]"]
  node_asset_schema["Asset Schema<br/>[Asset.py]"]
  node_asset_type["Asset Types<br/>[AssetTypeEnum.py]"]
  node_chunk_model["Chunk Records<br/>[ChunkModel.py]"]
  node_chunk_schema["Chunk Schema<br/>[DataChunk.py]"]
end

node_client(("API Client"))
node_database[("MongoDB")]

node_client -->|"sends requests"| node_app
node_app -->|"mounts route"| node_health
node_app -->|"mounts route"| node_data_routes
node_client -->|"checks health"| node_health
node_client -->|"uploads or processes"| node_data_routes
node_data_routes -->|"reads settings"| node_settings
node_data_routes -->|"validates uploads"| node_data_controller
node_data_controller -->|"gets project path"| node_project_controller
node_data_routes -->|"gets project path"| node_project_controller
node_data_controller -->|"inherits"| node_base_controller
node_project_controller -->|"inherits"| node_base_controller
node_data_routes -->|"creates or gets project"| node_project_model
node_data_routes -->|"creates asset record"| node_asset_model
node_data_routes -->|"builds asset"| node_asset_schema
node_data_routes -->|"sets asset type"| node_asset_type
node_data_routes -->|"accepts parameters"| node_process_request
node_data_routes -->|"loads and splits files"| node_process_controller
node_process_controller -->|"gets project path"| node_project_controller
node_process_controller -->|"selects file loader"| node_processing_types
node_data_routes -->|"resets and stores chunks"| node_chunk_model
node_data_routes -->|"builds chunks"| node_chunk_schema
node_asset_model -.->|"persists records"| node_database
node_project_model -.->|"persists records"| node_database
node_chunk_model -.->|"persists chunks"| node_database

click node_app "https://github.com/a7medrajab1/mini-rag/blob/main/src/main.py"
click node_health "https://github.com/a7medrajab1/mini-rag/blob/main/src/routes/base.py"
click node_data_routes "https://github.com/a7medrajab1/mini-rag/blob/main/src/routes/data.py"
click node_process_request "https://github.com/a7medrajab1/mini-rag/blob/main/src/routes/schemes/data.py"
click node_settings "https://github.com/a7medrajab1/mini-rag/blob/main/src/helpers/config.py"
click node_data_controller "https://github.com/a7medrajab1/mini-rag/blob/main/src/controllers/DataController.py"
click node_project_controller "https://github.com/a7medrajab1/mini-rag/blob/main/src/controllers/ProjectController.py"
click node_base_controller "https://github.com/a7medrajab1/mini-rag/blob/main/src/controllers/BaseController.py"
click node_asset_model "https://github.com/a7medrajab1/mini-rag/blob/main/src/models/AssetModel.py"
click node_project_model "https://github.com/a7medrajab1/mini-rag/blob/main/src/models/ProjectModel.py"
click node_asset_schema "https://github.com/a7medrajab1/mini-rag/blob/main/src/models/db_schemes/Asset.py"
click node_asset_type "https://github.com/a7medrajab1/mini-rag/blob/main/src/models/enums/AssetTypeEnum.py"
click node_process_controller "https://github.com/a7medrajab1/mini-rag/blob/main/src/controllers/ProcessController.py"
click node_processing_types "https://github.com/a7medrajab1/mini-rag/blob/main/src/models/enums/ProcessingEnum.py"
click node_chunk_model "https://github.com/a7medrajab1/mini-rag/blob/main/src/models/ChunkModel.py"
click node_chunk_schema "https://github.com/a7medrajab1/mini-rag/blob/main/src/models/db_schemes/DataChunk.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_health,node_data_routes,node_process_request,node_settings,node_client toneBlue
class node_data_controller,node_project_controller,node_base_controller,node_database toneAmber
class node_process_controller,node_processing_types toneMint
class node_asset_model,node_project_model,node_asset_schema,node_asset_type,node_chunk_model,node_chunk_schema toneRose
```

## Components

### HTTP API

- [FastAPI App](https://github.com/a7medrajab1/mini-rag/blob/main/src/main.py): `src/main.py`
- [Health Route](https://github.com/a7medrajab1/mini-rag/blob/main/src/routes/base.py): `src/routes/base.py`
- [Data Routes](https://github.com/a7medrajab1/mini-rag/blob/main/src/routes/data.py): `src/routes/data.py`
- [Process Request](https://github.com/a7medrajab1/mini-rag/blob/main/src/routes/schemes/data.py): `src/routes/schemes/data.py`
- [Settings](https://github.com/a7medrajab1/mini-rag/blob/main/src/helpers/config.py): `src/helpers/config.py`

### File Ingestion

- [Upload Validation](https://github.com/a7medrajab1/mini-rag/blob/main/src/controllers/DataController.py): `src/controllers/DataController.py`
- [Project Files](https://github.com/a7medrajab1/mini-rag/blob/main/src/controllers/ProjectController.py): `src/controllers/ProjectController.py`
- [Controller Base](https://github.com/a7medrajab1/mini-rag/blob/main/src/controllers/BaseController.py): `src/controllers/BaseController.py`

### Text Processing

- [File Processing](https://github.com/a7medrajab1/mini-rag/blob/main/src/controllers/ProcessController.py): `src/controllers/ProcessController.py`
- [File Types](https://github.com/a7medrajab1/mini-rag/blob/main/src/models/enums/ProcessingEnum.py): `src/models/enums/ProcessingEnum.py`

### Persistence

- [Asset Records](https://github.com/a7medrajab1/mini-rag/blob/main/src/models/AssetModel.py): `src/models/AssetModel.py`
- [Project Records](https://github.com/a7medrajab1/mini-rag/blob/main/src/models/ProjectModel.py): `src/models/ProjectModel.py`
- [Asset Schema](https://github.com/a7medrajab1/mini-rag/blob/main/src/models/db_schemes/Asset.py): `src/models/db_schemes/Asset.py`
- [Asset Types](https://github.com/a7medrajab1/mini-rag/blob/main/src/models/enums/AssetTypeEnum.py): `src/models/enums/AssetTypeEnum.py`
- [Chunk Records](https://github.com/a7medrajab1/mini-rag/blob/main/src/models/ChunkModel.py): `src/models/ChunkModel.py`
- [Chunk Schema](https://github.com/a7medrajab1/mini-rag/blob/main/src/models/db_schemes/DataChunk.py): `src/models/db_schemes/DataChunk.py`

### Other components

- **API Client**
- **MongoDB**

## Connections

- API Client → FastAPI App: sends requests (evidence: `src/main.py`)
- FastAPI App → Health Route: mounts route (evidence: `src/main.py`)
- FastAPI App → Data Routes: mounts route (evidence: `src/main.py`)
- API Client → Health Route: checks health (evidence: `src/routes/base.py`)
- API Client → Data Routes: uploads or processes (evidence: `src/routes/data.py`)
- Data Routes → Settings: reads settings (evidence: `src/routes/data.py`)
- Data Routes → Upload Validation: validates uploads (evidence: `src/routes/data.py`)
- Upload Validation → Project Files: gets project path (evidence: `src/controllers/DataController.py`)
- Data Routes → Project Files: gets project path (evidence: `src/routes/data.py`)
- Upload Validation → Controller Base: inherits (evidence: `src/controllers/DataController.py`)
- Project Files → Controller Base: inherits (evidence: `src/controllers/ProjectController.py`)
- Data Routes → Project Records: creates or gets project (evidence: `src/routes/data.py`)
- Data Routes → Asset Records: creates asset record (evidence: `src/routes/data.py`)
- Data Routes → Asset Schema: builds asset (evidence: `src/routes/data.py`)
- Data Routes → Asset Types: sets asset type (evidence: `src/routes/data.py`)
- Data Routes → Process Request: accepts parameters (evidence: `src/routes/data.py`)
- Data Routes → File Processing: loads and splits files (evidence: `src/routes/data.py`)
- File Processing → Project Files: gets project path (evidence: `src/controllers/ProcessController.py`)
- File Processing → File Types: selects file loader (evidence: `src/controllers/ProcessController.py`)
- Data Routes → Chunk Records: resets and stores chunks (evidence: `src/routes/data.py`)
- Data Routes → Chunk Schema: builds chunks (evidence: `src/routes/data.py`)
- Asset Records → MongoDB: persists records
- Project Records → MongoDB: persists records
- Chunk Records → MongoDB: persists chunks
