# mouad-melloul/rag_chatbot architecture

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

- Interactive diagram: https://gitdiagram.com/mouad-melloul/rag_chatbot
- Repository: https://github.com/mouad-melloul/rag_chatbot

## Overview

A local PDF question-answering application: users upload PDFs through a browser, the API processes and indexes their text, and questions are answered using retrieved context and Ollama. The graph emphasizes the active route-to-RAG path. The separate vector-store and LLM manager modules are included as code components, but the excerpts do not show them being called by that path.

Main entry points: [`BACKEND/app/config.py`](https://github.com/mouad-melloul/rag_chatbot/blob/main/BACKEND/app/config.py) (Runtime settings), [`BACKEND/app/api/routes.py`](https://github.com/mouad-melloul/rag_chatbot/blob/main/BACKEND/app/api/routes.py) (API routes), [`BACKEND/app/rag/pipeline.py`](https://github.com/mouad-melloul/rag_chatbot/blob/main/BACKEND/app/rag/pipeline.py) (RAG pipeline), [`BACKEND/app/main.py`](https://github.com/mouad-melloul/rag_chatbot/blob/main/BACKEND/app/main.py) (FastAPI app)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Browser interface"]
  node_frontend["Chat interface<br/>[app.js]"]
end

subgraph group_api["API and uploads"]
  node_api_app["FastAPI app<br/>[main.py]"]
  node_routes["API routes<br/>[routes.py]"]
  node_upload_storage["PDF uploads<br/>[config.py]"]
end

subgraph group_rag["Document RAG"]
  node_pipeline["RAG pipeline<br/>[pipeline.py]"]
  node_processor["PDF extraction"]
  node_vector_store["Vector store manager<br/>[vector_store.py]"]
  node_llm_manager["LLM manager<br/>[llm.py]"]
end

subgraph group_integrations["Runtime integrations"]
  node_config["Runtime settings<br/>[config.py]"]
  node_ollama{{"Ollama service"}}
end

node_user(("User"))

node_user -->|"asks and uploads"| node_frontend
node_frontend -->|"calls API"| node_routes
node_api_app -->|"registers routes"| node_routes
node_routes -->|"writes PDFs"| node_upload_storage
node_routes -->|"uploads, asks, clears"| node_pipeline
node_pipeline -->|"extracts and splits"| node_processor
node_pipeline -->|"embeds and generates"| node_ollama
node_routes -->|"reads upload settings"| node_config
node_api_app -->|"reads upload path"| node_config
node_processor -->|"reads chunk settings"| node_config
node_pipeline -->|"reads RAG settings"| node_config
node_vector_store -->|"creates embeddings"| node_ollama
node_vector_store -->|"reads retrieval settings"| node_config
node_llm_manager -->|"creates model client"| node_ollama
node_llm_manager -->|"reads model settings"| node_config

click node_frontend "https://github.com/mouad-melloul/rag_chatbot/blob/main/FRONTEND/js/app.js"
click node_api_app "https://github.com/mouad-melloul/rag_chatbot/blob/main/BACKEND/app/main.py"
click node_routes "https://github.com/mouad-melloul/rag_chatbot/blob/main/BACKEND/app/api/routes.py"
click node_upload_storage "https://github.com/mouad-melloul/rag_chatbot/blob/main/BACKEND/app/config.py"
click node_config "https://github.com/mouad-melloul/rag_chatbot/blob/main/BACKEND/app/config.py"
click node_pipeline "https://github.com/mouad-melloul/rag_chatbot/blob/main/BACKEND/app/rag/pipeline.py"
click node_processor "https://github.com/mouad-melloul/rag_chatbot/blob/main/BACKEND/app/rag/document_processor.py"
click node_vector_store "https://github.com/mouad-melloul/rag_chatbot/blob/main/BACKEND/app/rag/vector_store.py"
click node_llm_manager "https://github.com/mouad-melloul/rag_chatbot/blob/main/BACKEND/app/rag/llm.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_frontend,node_user toneBlue
class node_api_app,node_routes,node_upload_storage toneAmber
class node_pipeline,node_processor,node_vector_store,node_llm_manager toneMint
class node_config,node_ollama toneRose
```

## Components

### Browser interface

- [Chat interface](https://github.com/mouad-melloul/rag_chatbot/blob/main/FRONTEND/js/app.js): `FRONTEND/js/app.js`

### API and uploads

- [FastAPI app](https://github.com/mouad-melloul/rag_chatbot/blob/main/BACKEND/app/main.py): `BACKEND/app/main.py`
- [API routes](https://github.com/mouad-melloul/rag_chatbot/blob/main/BACKEND/app/api/routes.py): `BACKEND/app/api/routes.py`
- [PDF uploads](https://github.com/mouad-melloul/rag_chatbot/blob/main/BACKEND/app/config.py): `BACKEND/app/config.py`

### Document RAG

- [RAG pipeline](https://github.com/mouad-melloul/rag_chatbot/blob/main/BACKEND/app/rag/pipeline.py): `BACKEND/app/rag/pipeline.py`
- [PDF extraction](https://github.com/mouad-melloul/rag_chatbot/blob/main/BACKEND/app/rag/document_processor.py): `BACKEND/app/rag/document_processor.py`
- [Vector store manager](https://github.com/mouad-melloul/rag_chatbot/blob/main/BACKEND/app/rag/vector_store.py): `BACKEND/app/rag/vector_store.py`
- [LLM manager](https://github.com/mouad-melloul/rag_chatbot/blob/main/BACKEND/app/rag/llm.py): `BACKEND/app/rag/llm.py`

### Runtime integrations

- [Runtime settings](https://github.com/mouad-melloul/rag_chatbot/blob/main/BACKEND/app/config.py): `BACKEND/app/config.py`
- **Ollama service**

### Other components

- **User**

## Connections

- User → Chat interface: asks and uploads (evidence: `README.md`)
- Chat interface → API routes: calls API (evidence: `FRONTEND/js/app.js`)
- FastAPI app → API routes: registers routes (evidence: `BACKEND/app/main.py`)
- API routes → PDF uploads: writes PDFs (evidence: `BACKEND/app/api/routes.py`)
- API routes → RAG pipeline: uploads, asks, clears (evidence: `BACKEND/app/api/routes.py`)
- RAG pipeline → PDF extraction: extracts and splits (evidence: `BACKEND/app/rag/pipeline.py`)
- RAG pipeline → Ollama service: embeds and generates (evidence: `BACKEND/app/rag/pipeline.py`)
- API routes → Runtime settings: reads upload settings (evidence: `BACKEND/app/api/routes.py`)
- FastAPI app → Runtime settings: reads upload path (evidence: `BACKEND/app/main.py`)
- PDF extraction → Runtime settings: reads chunk settings (evidence: `BACKEND/app/rag/document_processor.py`)
- RAG pipeline → Runtime settings: reads RAG settings (evidence: `BACKEND/app/rag/pipeline.py`)
- Vector store manager → Ollama service: creates embeddings (evidence: `BACKEND/app/rag/vector_store.py`)
- Vector store manager → Runtime settings: reads retrieval settings (evidence: `BACKEND/app/rag/vector_store.py`)
- LLM manager → Ollama service: creates model client (evidence: `BACKEND/app/rag/llm.py`)
- LLM manager → Runtime settings: reads model settings (evidence: `BACKEND/app/rag/llm.py`)
