# ibrahimabalde09/rag-assurance-chatbot- architecture

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

- Interactive diagram: https://gitdiagram.com/ibrahimabalde09/rag-assurance-chatbot-
- Repository: https://github.com/ibrahimabalde09/rag-assurance-chatbot-

## Overview

Le produit est un chatbot conversationnel spécialisé en assurance, banque et immobilier. Le parcours principal va de l’interface web à l’API, puis au pipeline RAG : classification du domaine, recherche documentaire, génération contextualisée ou générale, et persistance de l’échange. La construction de l’index documentaire est une branche distincte qui alimente la recherche à l’exécution. Le README documente aussi l’évaluation quantitative. Les liens détaillés reflètent les extraits disponibles ; les implémentations de génération, modèles et endpoints de santé n’ont pas été échantillonnés.

Main entry points: [`app/main.py`](https://github.com/ibrahimabalde09/rag-assurance-chatbot-/blob/main/app/main.py) (Application FastAPI), [`app/api/chat.py`](https://github.com/ibrahimabalde09/rag-assurance-chatbot-/blob/main/app/api/chat.py) (Endpoint chat), [`app/rag/pipeline.py`](https://github.com/ibrahimabalde09/rag-assurance-chatbot-/blob/main/app/rag/pipeline.py) (Pipeline RAG), [`evaluation/evaluate.py`](https://github.com/ibrahimabalde09/rag-assurance-chatbot-/blob/main/evaluation/evaluate.py) (Évaluation RAG)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Interface web"]
  node_frontend["Chat web<br/>[app.js]"]
end

subgraph group_service["API et orchestration"]
  node_api["Application FastAPI<br/>[main.py]"]
  node_chat["Endpoint chat<br/>[chat.py]"]
  node_schemas["Schémas API<br/>[schemas.py]"]
  node_health["Santé API<br/>[health.py]"]
  node_config["Configuration<br/>[config.py]"]
  node_pipeline["Pipeline RAG<br/>[pipeline.py]"]
  node_router["Routage domaine<br/>[router.py]"]
  node_generator["Génération réponse<br/>[generator.py]"]
  node_prompts["Prompts RAG<br/>[prompts.py]"]
end

subgraph group_knowledge["Base documentaire"]
  node_retriever["Recherche FAISS<br/>[retriever.py]"]
  node_raw_docs["Corpus source"]
  node_loader["Chargement textes<br/>[loader.py]"]
  node_splitter["Découpage chunks<br/>[splitter.py]"]
  node_index_builder["Construction index<br/>[build_index.py]"]
  node_processed["Chunks enrichis<br/>[chunks.json]"]
  node_vectorstore[("Index et documents")]
end

subgraph group_history["Historique conversationnel"]
  node_db_session["Session SQL<br/>[session.py]"]
  node_db_models["Modèles conversation<br/>[models.py]"]
  node_db[("Base historique")]
end

subgraph group_quality["Évaluation"]
  node_evaluation["Évaluation RAG<br/>[evaluate.py]"]
  node_golden["Questions de référence"]
end

node_user(("Utilisateur"))
node_openai{{"OpenAI LLM"}}

node_user -->|"saisit question"| node_frontend
node_frontend -->|"charge interface"| node_api
node_frontend -->|"envoie message"| node_chat
node_api -->|"monte route"| node_chat
node_api -->|"monte route"| node_health
node_api -->|"lit réglages"| node_config
node_api -->|"initialise base"| node_db_session
node_api -->|"crée pipeline"| node_pipeline
node_chat -->|"valide échange"| node_schemas
node_chat -->|"obtient session"| node_db_session
node_chat -->|"lit écrit"| node_db_models
node_chat -->|"traite question"| node_pipeline
node_pipeline -->|"classe domaine"| node_router
node_pipeline -->|"cherche passages"| node_retriever
node_pipeline -->|"génère réponse"| node_generator
node_retriever -->|"lit index"| node_vectorstore
node_generator -->|"utilise prompts"| node_prompts
node_generator -->|"appelle modèle"| node_openai
node_loader -->|"lit corpus"| node_raw_docs
node_index_builder -->|"charge documents"| node_loader
node_index_builder -->|"découpe textes"| node_splitter
node_index_builder -->|"écrit chunks"| node_processed
node_index_builder -->|"construit index"| node_vectorstore
node_db_session -->|"ouvre session"| node_db
node_db_models -->|"définit tables"| node_db
node_evaluation -->|"lit questions"| node_golden
node_evaluation -->|"mesure routage"| node_router
node_evaluation -->|"mesure recherche"| node_retriever
node_evaluation -.->|"évalue génération"| node_pipeline
node_evaluation -.->|"juge réponses"| node_openai

click node_frontend "https://github.com/ibrahimabalde09/rag-assurance-chatbot-/blob/main/static/app.js"
click node_api "https://github.com/ibrahimabalde09/rag-assurance-chatbot-/blob/main/app/main.py"
click node_chat "https://github.com/ibrahimabalde09/rag-assurance-chatbot-/blob/main/app/api/chat.py"
click node_schemas "https://github.com/ibrahimabalde09/rag-assurance-chatbot-/blob/main/app/api/schemas.py"
click node_health "https://github.com/ibrahimabalde09/rag-assurance-chatbot-/blob/main/app/api/health.py"
click node_config "https://github.com/ibrahimabalde09/rag-assurance-chatbot-/blob/main/app/core/config.py"
click node_pipeline "https://github.com/ibrahimabalde09/rag-assurance-chatbot-/blob/main/app/rag/pipeline.py"
click node_router "https://github.com/ibrahimabalde09/rag-assurance-chatbot-/blob/main/app/rag/router.py"
click node_retriever "https://github.com/ibrahimabalde09/rag-assurance-chatbot-/blob/main/app/rag/retriever.py"
click node_generator "https://github.com/ibrahimabalde09/rag-assurance-chatbot-/blob/main/app/rag/generator.py"
click node_prompts "https://github.com/ibrahimabalde09/rag-assurance-chatbot-/blob/main/app/rag/prompts.py"
click node_raw_docs "https://github.com/ibrahimabalde09/rag-assurance-chatbot-/tree/main/data/raw"
click node_loader "https://github.com/ibrahimabalde09/rag-assurance-chatbot-/blob/main/ingestion/loader.py"
click node_splitter "https://github.com/ibrahimabalde09/rag-assurance-chatbot-/blob/main/ingestion/splitter.py"
click node_index_builder "https://github.com/ibrahimabalde09/rag-assurance-chatbot-/blob/main/ingestion/build_index.py"
click node_processed "https://github.com/ibrahimabalde09/rag-assurance-chatbot-/blob/main/data/processed/chunks.json"
click node_vectorstore "https://github.com/ibrahimabalde09/rag-assurance-chatbot-/tree/main/data/vectorstore"
click node_db_session "https://github.com/ibrahimabalde09/rag-assurance-chatbot-/blob/main/app/db/session.py"
click node_db_models "https://github.com/ibrahimabalde09/rag-assurance-chatbot-/blob/main/app/db/models.py"
click node_evaluation "https://github.com/ibrahimabalde09/rag-assurance-chatbot-/blob/main/evaluation/evaluate.py"
click node_golden "https://github.com/ibrahimabalde09/rag-assurance-chatbot-/blob/main/evaluation/golden_dataset.json"

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 toneBlue
class node_api,node_chat,node_schemas,node_health,node_config,node_pipeline,node_router,node_generator,node_prompts toneAmber
class node_retriever,node_raw_docs,node_loader,node_splitter,node_index_builder,node_processed,node_vectorstore toneMint
class node_db_session,node_db_models,node_db toneRose
class node_evaluation,node_golden,node_user,node_openai toneIndigo
```

## Components

### Interface web

- [Chat web](https://github.com/ibrahimabalde09/rag-assurance-chatbot-/blob/main/static/app.js): `static/app.js`

### API et orchestration

- [Application FastAPI](https://github.com/ibrahimabalde09/rag-assurance-chatbot-/blob/main/app/main.py): `app/main.py`
- [Endpoint chat](https://github.com/ibrahimabalde09/rag-assurance-chatbot-/blob/main/app/api/chat.py): `app/api/chat.py`
- [Schémas API](https://github.com/ibrahimabalde09/rag-assurance-chatbot-/blob/main/app/api/schemas.py): `app/api/schemas.py`
- [Santé API](https://github.com/ibrahimabalde09/rag-assurance-chatbot-/blob/main/app/api/health.py): `app/api/health.py`
- [Configuration](https://github.com/ibrahimabalde09/rag-assurance-chatbot-/blob/main/app/core/config.py): `app/core/config.py`
- [Pipeline RAG](https://github.com/ibrahimabalde09/rag-assurance-chatbot-/blob/main/app/rag/pipeline.py): `app/rag/pipeline.py`
- [Routage domaine](https://github.com/ibrahimabalde09/rag-assurance-chatbot-/blob/main/app/rag/router.py): `app/rag/router.py`
- [Génération réponse](https://github.com/ibrahimabalde09/rag-assurance-chatbot-/blob/main/app/rag/generator.py): `app/rag/generator.py`
- [Prompts RAG](https://github.com/ibrahimabalde09/rag-assurance-chatbot-/blob/main/app/rag/prompts.py): `app/rag/prompts.py`

### Base documentaire

- [Recherche FAISS](https://github.com/ibrahimabalde09/rag-assurance-chatbot-/blob/main/app/rag/retriever.py): `app/rag/retriever.py`
- [Corpus source](https://github.com/ibrahimabalde09/rag-assurance-chatbot-/tree/main/data/raw): `data/raw`
- [Chargement textes](https://github.com/ibrahimabalde09/rag-assurance-chatbot-/blob/main/ingestion/loader.py): `ingestion/loader.py`
- [Découpage chunks](https://github.com/ibrahimabalde09/rag-assurance-chatbot-/blob/main/ingestion/splitter.py): `ingestion/splitter.py`
- [Construction index](https://github.com/ibrahimabalde09/rag-assurance-chatbot-/blob/main/ingestion/build_index.py): `ingestion/build_index.py`
- [Chunks enrichis](https://github.com/ibrahimabalde09/rag-assurance-chatbot-/blob/main/data/processed/chunks.json): `data/processed/chunks.json`
- [Index et documents](https://github.com/ibrahimabalde09/rag-assurance-chatbot-/tree/main/data/vectorstore): `data/vectorstore`

### Historique conversationnel

- [Session SQL](https://github.com/ibrahimabalde09/rag-assurance-chatbot-/blob/main/app/db/session.py): `app/db/session.py`
- [Modèles conversation](https://github.com/ibrahimabalde09/rag-assurance-chatbot-/blob/main/app/db/models.py): `app/db/models.py`
- **Base historique**

### Évaluation

- [Évaluation RAG](https://github.com/ibrahimabalde09/rag-assurance-chatbot-/blob/main/evaluation/evaluate.py): `evaluation/evaluate.py`
- [Questions de référence](https://github.com/ibrahimabalde09/rag-assurance-chatbot-/blob/main/evaluation/golden_dataset.json): `evaluation/golden_dataset.json`

### Other components

- **Utilisateur**
- **OpenAI LLM**

## Connections

- Utilisateur → Chat web: saisit question
- Chat web → Application FastAPI: charge interface
- Chat web → Endpoint chat: envoie message
- Application FastAPI → Endpoint chat: monte route
- Application FastAPI → Santé API: monte route
- Application FastAPI → Configuration: lit réglages
- Application FastAPI → Session SQL: initialise base
- Application FastAPI → Pipeline RAG: crée pipeline
- Endpoint chat → Schémas API: valide échange
- Endpoint chat → Session SQL: obtient session
- Endpoint chat → Modèles conversation: lit écrit
- Endpoint chat → Pipeline RAG: traite question
- Pipeline RAG → Routage domaine: classe domaine
- Pipeline RAG → Recherche FAISS: cherche passages
- Pipeline RAG → Génération réponse: génère réponse
- Recherche FAISS → Index et documents: lit index
- Génération réponse → Prompts RAG: utilise prompts
- Génération réponse → OpenAI LLM: appelle modèle
- Chargement textes → Corpus source: lit corpus
- Construction index → Chargement textes: charge documents
- Construction index → Découpage chunks: découpe textes
- Construction index → Chunks enrichis: écrit chunks
- Construction index → Index et documents: construit index
- Session SQL → Base historique: ouvre session
- Modèles conversation → Base historique: définit tables
- Évaluation RAG → Questions de référence: lit questions
- Évaluation RAG → Routage domaine: mesure routage
- Évaluation RAG → Recherche FAISS: mesure recherche
- Évaluation RAG → Pipeline RAG: évalue génération
- Évaluation RAG → OpenAI LLM: juge réponses
