# adil-soudri/plateforme-intelligente-marches-publics architecture

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

- Interactive diagram: https://gitdiagram.com/adil-soudri/plateforme-intelligente-marches-publics
- Repository: https://github.com/adil-soudri/plateforme-intelligente-marches-publics

## Overview

This is a French-language document-management and question-answering application: users upload documents and ask questions, while administrators manage reference documents and users. The backend indexes uploads and answers questions through hybrid retrieval, context construction, and generation; it also provides authentication, chat history, and document administration. The frontend exposes user and administrator workflows. Some frontend-to-API and indexing internals are not evidenced by the excerpts, so those links are omitted; the indexed RAG service calls are visible, though some of its detailed implementation was not sampled.

Main entry points: [`backend/app/main.py`](https://github.com/adil-soudri/plateforme-intelligente-marches-publics/blob/main/backend/app/main.py) (FastAPI app), [`backend/app/controllers/chat_controller.py`](https://github.com/adil-soudri/plateforme-intelligente-marches-publics/blob/main/backend/app/controllers/chat_controller.py) (Chat endpoints), [`backend/app/services/auth_service.py`](https://github.com/adil-soudri/plateforme-intelligente-marches-publics/blob/main/backend/app/services/auth_service.py) (Authentication), [`backend/app/services/rag/rag_service.py`](https://github.com/adil-soudri/plateforme-intelligente-marches-publics/blob/main/backend/app/services/rag/rag_service.py) (RAG orchestration)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_frontend["Web application"]
  node_user_web["User workspace<br/>[page.tsx]"]
  node_chat_ui["Chat interface<br/>[ChatBox.tsx]"]
  node_chat_history_ui["Chat history<br/>[page.tsx]"]
  node_admin_docs_ui["Document admin<br/>[page.tsx]"]
  node_admin_users_ui["User admin<br/>[page.tsx]"]
end

subgraph group_api["API and access"]
  node_api_app["FastAPI app<br/>[main.py]"]
  node_chat_api["Chat endpoints<br/>[chat_controller.py]"]
  node_auth_api["Auth endpoints<br/>[auth_controller.py]"]
  node_import_api["User document API"]
  node_reference_api["Reference document API"]
  node_database[("Relational database<br/>[database.py]")]
end

subgraph group_identity["Identity and accounts"]
  node_access["Token access control<br/>[dependencies.py]"]
  node_security["Token security<br/>[security.py]"]
  node_auth_service["Authentication<br/>[auth_service.py]"]
  node_user_repo["User repository"]
  node_admin_repo["Admin repository"]
end

subgraph group_documents["Document management"]
  node_import_service["Imported documents"]
  node_reference_service["Reference documents"]
  node_indexing["Document indexing"]
end

subgraph group_answers["Question answering"]
  node_chat_service["Chat records<br/>[chat_service.py]"]
  node_rag["RAG orchestration<br/>[rag_service.py]"]
  node_hybrid["Hybrid retrieval"]
  node_vector["Vector retrieval"]
  node_embedding["Text embeddings"]
  node_context["Context assembly<br/>[context_service.py]"]
  node_generation["Answer generation"]
end

node_user(("User"))
node_admin(("Administrator"))

node_api_app -->|"registers routes"| node_chat_api
node_api_app -->|"registers routes"| node_auth_api
node_api_app -->|"registers routes"| node_import_api
node_api_app -->|"registers routes"| node_reference_api
node_chat_api -->|"asks questions"| node_rag
node_chat_api -->|"saves chat"| node_chat_service
node_chat_api -->|"opens session"| node_database
node_auth_api -->|"delegates login"| node_auth_service
node_auth_service -->|"looks up users"| node_user_repo
node_auth_service -->|"looks up admins"| node_admin_repo
node_auth_service -->|"verifies and signs"| node_security
node_access -->|"decodes token"| node_security
node_import_api -->|"stores document"| node_import_service
node_import_api -->|"indexes upload"| node_indexing
node_reference_api -->|"stores document"| node_reference_service
node_reference_api -->|"indexes upload"| node_indexing
node_rag -->|"retrieves passages"| node_hybrid
node_rag -->|"builds context"| node_context
node_rag -->|"generates answer"| node_generation
node_hybrid -->|"uses vector search"| node_vector
node_vector -->|"embeds query"| node_embedding
node_user -.-> node_user_web
node_user -.-> node_chat_ui
node_admin -.-> node_admin_docs_ui
node_admin -.-> node_admin_users_ui

click node_user_web "https://github.com/adil-soudri/plateforme-intelligente-marches-publics/blob/main/frontend/app/dashboard/page.tsx"
click node_chat_ui "https://github.com/adil-soudri/plateforme-intelligente-marches-publics/blob/main/frontend/components/ChatBox.tsx"
click node_chat_history_ui "https://github.com/adil-soudri/plateforme-intelligente-marches-publics/blob/main/frontend/app/chat/historique/page.tsx"
click node_admin_docs_ui "https://github.com/adil-soudri/plateforme-intelligente-marches-publics/blob/main/frontend/app/admin/documents/page.tsx"
click node_admin_users_ui "https://github.com/adil-soudri/plateforme-intelligente-marches-publics/blob/main/frontend/app/admin/utilisateurs/page.tsx"
click node_api_app "https://github.com/adil-soudri/plateforme-intelligente-marches-publics/blob/main/backend/app/main.py"
click node_chat_api "https://github.com/adil-soudri/plateforme-intelligente-marches-publics/blob/main/backend/app/controllers/chat_controller.py"
click node_auth_api "https://github.com/adil-soudri/plateforme-intelligente-marches-publics/blob/main/backend/app/controllers/auth_controller.py"
click node_import_api "https://github.com/adil-soudri/plateforme-intelligente-marches-publics/blob/main/backend/app/controllers/document_importe_controller.py"
click node_reference_api "https://github.com/adil-soudri/plateforme-intelligente-marches-publics/blob/main/backend/app/controllers/document_reference_controller.py"
click node_access "https://github.com/adil-soudri/plateforme-intelligente-marches-publics/blob/main/backend/app/core/dependencies.py"
click node_security "https://github.com/adil-soudri/plateforme-intelligente-marches-publics/blob/main/backend/app/core/security.py"
click node_auth_service "https://github.com/adil-soudri/plateforme-intelligente-marches-publics/blob/main/backend/app/services/auth_service.py"
click node_user_repo "https://github.com/adil-soudri/plateforme-intelligente-marches-publics/blob/main/backend/app/repositories/utilisateur_repository.py"
click node_admin_repo "https://github.com/adil-soudri/plateforme-intelligente-marches-publics/blob/main/backend/app/repositories/administrateur_repository.py"
click node_chat_service "https://github.com/adil-soudri/plateforme-intelligente-marches-publics/blob/main/backend/app/services/chat_service.py"
click node_rag "https://github.com/adil-soudri/plateforme-intelligente-marches-publics/blob/main/backend/app/services/rag/rag_service.py"
click node_hybrid "https://github.com/adil-soudri/plateforme-intelligente-marches-publics/blob/main/backend/app/services/document/hybrid_search_service.py"
click node_vector "https://github.com/adil-soudri/plateforme-intelligente-marches-publics/blob/main/backend/app/services/document/vector_search_service.py"
click node_embedding "https://github.com/adil-soudri/plateforme-intelligente-marches-publics/blob/main/backend/app/services/document/embedding_service.py"
click node_context "https://github.com/adil-soudri/plateforme-intelligente-marches-publics/blob/main/backend/app/services/rag/context_service.py"
click node_generation "https://github.com/adil-soudri/plateforme-intelligente-marches-publics/blob/main/backend/app/services/rag/generation_service.py"
click node_import_service "https://github.com/adil-soudri/plateforme-intelligente-marches-publics/blob/main/backend/app/services/document_importe_service.py"
click node_reference_service "https://github.com/adil-soudri/plateforme-intelligente-marches-publics/blob/main/backend/app/services/document_reference_service.py"
click node_indexing "https://github.com/adil-soudri/plateforme-intelligente-marches-publics/blob/main/backend/app/services/document/document_indexation_service.py"
click node_database "https://github.com/adil-soudri/plateforme-intelligente-marches-publics/blob/main/backend/app/core/database.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_user_web,node_chat_ui,node_chat_history_ui,node_admin_docs_ui,node_admin_users_ui,node_user toneBlue
class node_api_app,node_chat_api,node_auth_api,node_import_api,node_reference_api,node_database toneAmber
class node_access,node_security,node_auth_service,node_user_repo,node_admin_repo toneMint
class node_import_service,node_reference_service,node_indexing toneRose
class node_chat_service,node_rag,node_hybrid,node_vector,node_embedding,node_context,node_generation,node_admin toneIndigo
```

## Components

### Web application

- [User workspace](https://github.com/adil-soudri/plateforme-intelligente-marches-publics/blob/main/frontend/app/dashboard/page.tsx): `frontend/app/dashboard/page.tsx`
- [Chat interface](https://github.com/adil-soudri/plateforme-intelligente-marches-publics/blob/main/frontend/components/ChatBox.tsx): `frontend/components/ChatBox.tsx`
- [Chat history](https://github.com/adil-soudri/plateforme-intelligente-marches-publics/blob/main/frontend/app/chat/historique/page.tsx): `frontend/app/chat/historique/page.tsx`
- [Document admin](https://github.com/adil-soudri/plateforme-intelligente-marches-publics/blob/main/frontend/app/admin/documents/page.tsx): `frontend/app/admin/documents/page.tsx`
- [User admin](https://github.com/adil-soudri/plateforme-intelligente-marches-publics/blob/main/frontend/app/admin/utilisateurs/page.tsx): `frontend/app/admin/utilisateurs/page.tsx`

### API and access

- [FastAPI app](https://github.com/adil-soudri/plateforme-intelligente-marches-publics/blob/main/backend/app/main.py): `backend/app/main.py`
- [Chat endpoints](https://github.com/adil-soudri/plateforme-intelligente-marches-publics/blob/main/backend/app/controllers/chat_controller.py): `backend/app/controllers/chat_controller.py`
- [Auth endpoints](https://github.com/adil-soudri/plateforme-intelligente-marches-publics/blob/main/backend/app/controllers/auth_controller.py): `backend/app/controllers/auth_controller.py`
- [User document API](https://github.com/adil-soudri/plateforme-intelligente-marches-publics/blob/main/backend/app/controllers/document_importe_controller.py): `backend/app/controllers/document_importe_controller.py`
- [Reference document API](https://github.com/adil-soudri/plateforme-intelligente-marches-publics/blob/main/backend/app/controllers/document_reference_controller.py): `backend/app/controllers/document_reference_controller.py`
- [Relational database](https://github.com/adil-soudri/plateforme-intelligente-marches-publics/blob/main/backend/app/core/database.py): `backend/app/core/database.py`

### Identity and accounts

- [Token access control](https://github.com/adil-soudri/plateforme-intelligente-marches-publics/blob/main/backend/app/core/dependencies.py): `backend/app/core/dependencies.py`
- [Token security](https://github.com/adil-soudri/plateforme-intelligente-marches-publics/blob/main/backend/app/core/security.py): `backend/app/core/security.py`
- [Authentication](https://github.com/adil-soudri/plateforme-intelligente-marches-publics/blob/main/backend/app/services/auth_service.py): `backend/app/services/auth_service.py`
- [User repository](https://github.com/adil-soudri/plateforme-intelligente-marches-publics/blob/main/backend/app/repositories/utilisateur_repository.py): `backend/app/repositories/utilisateur_repository.py`
- [Admin repository](https://github.com/adil-soudri/plateforme-intelligente-marches-publics/blob/main/backend/app/repositories/administrateur_repository.py): `backend/app/repositories/administrateur_repository.py`

### Document management

- [Imported documents](https://github.com/adil-soudri/plateforme-intelligente-marches-publics/blob/main/backend/app/services/document_importe_service.py): `backend/app/services/document_importe_service.py`
- [Reference documents](https://github.com/adil-soudri/plateforme-intelligente-marches-publics/blob/main/backend/app/services/document_reference_service.py): `backend/app/services/document_reference_service.py`
- [Document indexing](https://github.com/adil-soudri/plateforme-intelligente-marches-publics/blob/main/backend/app/services/document/document_indexation_service.py): `backend/app/services/document/document_indexation_service.py`

### Question answering

- [Chat records](https://github.com/adil-soudri/plateforme-intelligente-marches-publics/blob/main/backend/app/services/chat_service.py): `backend/app/services/chat_service.py`
- [RAG orchestration](https://github.com/adil-soudri/plateforme-intelligente-marches-publics/blob/main/backend/app/services/rag/rag_service.py): `backend/app/services/rag/rag_service.py`
- [Hybrid retrieval](https://github.com/adil-soudri/plateforme-intelligente-marches-publics/blob/main/backend/app/services/document/hybrid_search_service.py): `backend/app/services/document/hybrid_search_service.py`
- [Vector retrieval](https://github.com/adil-soudri/plateforme-intelligente-marches-publics/blob/main/backend/app/services/document/vector_search_service.py): `backend/app/services/document/vector_search_service.py`
- [Text embeddings](https://github.com/adil-soudri/plateforme-intelligente-marches-publics/blob/main/backend/app/services/document/embedding_service.py): `backend/app/services/document/embedding_service.py`
- [Context assembly](https://github.com/adil-soudri/plateforme-intelligente-marches-publics/blob/main/backend/app/services/rag/context_service.py): `backend/app/services/rag/context_service.py`
- [Answer generation](https://github.com/adil-soudri/plateforme-intelligente-marches-publics/blob/main/backend/app/services/rag/generation_service.py): `backend/app/services/rag/generation_service.py`

### Other components

- **User**
- **Administrator**

## Connections

- FastAPI app → Chat endpoints: registers routes (evidence: `backend/app/main.py`)
- FastAPI app → Auth endpoints: registers routes (evidence: `backend/app/main.py`)
- FastAPI app → User document API: registers routes (evidence: `backend/app/main.py`)
- FastAPI app → Reference document API: registers routes (evidence: `backend/app/main.py`)
- Chat endpoints → RAG orchestration: asks questions (evidence: `backend/app/controllers/chat_controller.py`)
- Chat endpoints → Chat records: saves chat (evidence: `backend/app/controllers/chat_controller.py`)
- Chat endpoints → Relational database: opens session (evidence: `backend/app/controllers/chat_controller.py`)
- Auth endpoints → Authentication: delegates login (evidence: `backend/app/controllers/auth_controller.py`)
- Authentication → User repository: looks up users (evidence: `backend/app/services/auth_service.py`)
- Authentication → Admin repository: looks up admins (evidence: `backend/app/services/auth_service.py`)
- Authentication → Token security: verifies and signs (evidence: `backend/app/services/auth_service.py`)
- Token access control → Token security: decodes token (evidence: `backend/app/core/dependencies.py`)
- User document API → Imported documents: stores document (evidence: `backend/app/controllers/document_importe_controller.py`)
- User document API → Document indexing: indexes upload (evidence: `backend/app/controllers/document_importe_controller.py`)
- Reference document API → Reference documents: stores document (evidence: `backend/app/controllers/document_reference_controller.py`)
- Reference document API → Document indexing: indexes upload (evidence: `backend/app/controllers/document_reference_controller.py`)
- RAG orchestration → Hybrid retrieval: retrieves passages (evidence: `backend/app/services/rag/rag_service.py`)
- RAG orchestration → Context assembly: builds context (evidence: `backend/app/services/rag/rag_service.py`)
- RAG orchestration → Answer generation: generates answer (evidence: `backend/app/services/rag/rag_service.py`)
- Hybrid retrieval → Vector retrieval: uses vector search (evidence: `backend/app/services/document/hybrid_search_service.py`)
- Vector retrieval → Text embeddings: embeds query (evidence: `backend/app/services/document/vector_search_service.py`)
- User → User workspace
- User → Chat interface
- Administrator → Document admin
- Administrator → User admin
