# tcheunzy/projet_5_openclassrooms architecture

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

- Interactive diagram: https://gitdiagram.com/tcheunzy/projet_5_openclassrooms
- Repository: https://github.com/tcheunzy/projet_5_openclassrooms

## Overview

Futurisys’ product is a FastAPI service that accepts employee HR data, validates and authenticates prediction requests, returns a turnover-risk result, and records employee state plus a prediction history in PostgreSQL. The central flow is explicit in the API handler; the README also documents unauthenticated monitoring endpoints and historical employee-data import. Model and metadata loading are shown in the prediction module. The database is intended for local use; deployment and CI details are outside this runtime map.

Main entry points: [`api/main.py`](https://github.com/tcheunzy/projet_5_openclassrooms/blob/main/api/main.py) (FastAPI service), [`database/insert_dataset.py`](https://github.com/tcheunzy/projet_5_openclassrooms/blob/main/database/insert_dataset.py) (Historical employee import), [`database/connection.py`](https://github.com/tcheunzy/projet_5_openclassrooms/blob/main/database/connection.py) (DB session provider), [`database/models_db.py`](https://github.com/tcheunzy/projet_5_openclassrooms/blob/main/database/models_db.py) (Employee and prediction models)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_api["API boundary"]
  node_service["FastAPI service<br/>[main.py]"]
  node_schemas["Request and response schemas<br/>[schemas.py]"]
  node_auth["API-key verification<br/>[security.py]"]
end

subgraph group_prediction["Prediction"]
  node_predictor["Turnover predictor<br/>[predict.py]"]
  node_artifacts["Model artifacts"]
end

subgraph group_persistence["Persistence"]
  node_dbsession["DB session provider<br/>[connection.py]"]
  node_orm["Employee and prediction models<br/>[models_db.py]"]
end

subgraph group_data["Historical data"]
  node_dataset_import["Historical employee import<br/>[insert_dataset.py]"]
  node_historical_csv["Historical dataset"]
end

node_client(("HR client"))
node_postgres[("PostgreSQL")]

node_client -->|"submits request"| node_service
node_service -->|"validates request"| node_schemas
node_service -->|"verifies key"| node_auth
node_service -->|"requests prediction"| node_predictor
node_predictor -->|"loads model and metadata"| node_artifacts
node_service -->|"requests session"| node_dbsession
node_service -->|"queries and records"| node_orm
node_dbsession -->|"connects"| node_postgres
node_orm -->|"maps tables"| node_postgres
node_dataset_import -->|"reads"| node_historical_csv
node_dataset_import -->|"opens session"| node_dbsession
node_dataset_import -->|"inserts employees"| node_orm

click node_service "https://github.com/tcheunzy/projet_5_openclassrooms/blob/main/api/main.py"
click node_schemas "https://github.com/tcheunzy/projet_5_openclassrooms/blob/main/api/schemas.py"
click node_auth "https://github.com/tcheunzy/projet_5_openclassrooms/blob/main/api/security.py"
click node_predictor "https://github.com/tcheunzy/projet_5_openclassrooms/blob/main/src/predict.py"
click node_artifacts "https://github.com/tcheunzy/projet_5_openclassrooms/tree/main/models"
click node_dbsession "https://github.com/tcheunzy/projet_5_openclassrooms/blob/main/database/connection.py"
click node_orm "https://github.com/tcheunzy/projet_5_openclassrooms/blob/main/database/models_db.py"
click node_dataset_import "https://github.com/tcheunzy/projet_5_openclassrooms/blob/main/database/insert_dataset.py"
click node_historical_csv "https://github.com/tcheunzy/projet_5_openclassrooms/blob/main/data/processed/dataset_complet_historique.csv"

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_service,node_schemas,node_auth,node_client toneBlue
class node_predictor,node_artifacts,node_postgres toneAmber
class node_dbsession,node_orm toneMint
class node_dataset_import,node_historical_csv toneRose
```

## Components

### API boundary

- [FastAPI service](https://github.com/tcheunzy/projet_5_openclassrooms/blob/main/api/main.py): `api/main.py`
- [Request and response schemas](https://github.com/tcheunzy/projet_5_openclassrooms/blob/main/api/schemas.py): `api/schemas.py`
- [API-key verification](https://github.com/tcheunzy/projet_5_openclassrooms/blob/main/api/security.py): `api/security.py`

### Prediction

- [Turnover predictor](https://github.com/tcheunzy/projet_5_openclassrooms/blob/main/src/predict.py): `src/predict.py`
- [Model artifacts](https://github.com/tcheunzy/projet_5_openclassrooms/tree/main/models): `models`

### Persistence

- [DB session provider](https://github.com/tcheunzy/projet_5_openclassrooms/blob/main/database/connection.py): `database/connection.py`
- [Employee and prediction models](https://github.com/tcheunzy/projet_5_openclassrooms/blob/main/database/models_db.py): `database/models_db.py`

### Historical data

- [Historical employee import](https://github.com/tcheunzy/projet_5_openclassrooms/blob/main/database/insert_dataset.py): `database/insert_dataset.py`
- [Historical dataset](https://github.com/tcheunzy/projet_5_openclassrooms/blob/main/data/processed/dataset_complet_historique.csv): `data/processed/dataset_complet_historique.csv`

### Other components

- **HR client**
- **PostgreSQL**

## Connections

- HR client → FastAPI service: submits request (evidence: `README.md`)
- FastAPI service → Request and response schemas: validates request (evidence: `api/main.py`)
- FastAPI service → API-key verification: verifies key (evidence: `api/main.py`)
- FastAPI service → Turnover predictor: requests prediction (evidence: `api/main.py`)
- Turnover predictor → Model artifacts: loads model and metadata (evidence: `src/predict.py`)
- FastAPI service → DB session provider: requests session (evidence: `api/main.py`)
- FastAPI service → Employee and prediction models: queries and records (evidence: `api/main.py`)
- DB session provider → PostgreSQL: connects (evidence: `database/connection.py`)
- Employee and prediction models → PostgreSQL: maps tables (evidence: `database/models_db.py`)
- Historical employee import → Historical dataset: reads (evidence: `database/insert_dataset.py`)
- Historical employee import → DB session provider: opens session (evidence: `database/insert_dataset.py`)
- Historical employee import → Employee and prediction models: inserts employees (evidence: `database/insert_dataset.py`)
