# darshanafk123/employee-attrition architecture

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

- Interactive diagram: https://gitdiagram.com/darshanafk123/employee-attrition
- Repository: https://github.com/darshanafk123/employee-attrition

## Overview

Employee Attrition Predictor accepts employee details through a Spring Boot API, validates them, forwards them to a Python Flask service, and returns a leave/stay prediction with probabilities. The Flask service validates inputs, fills unspecified profile features, encodes and scales the profile, then runs a trained Logistic Regression model. Training is a separate capability that produces the model and scaler artifacts consumed at runtime. The tree contains a frontend entry file, but its implementation was not sampled; its behavior is not inferred here.

Main entry points: [`springboot-service/src/main/java/com/attrition/controller/PredictionController.java`](https://github.com/darshanafk123/employee-attrition/blob/main/springboot-service/src/main/java/com/attrition/controller/PredictionController.java) (Prediction endpoint), [`python-service/app.py`](https://github.com/darshanafk123/employee-attrition/blob/main/python-service/app.py) (Prediction and health API), [`python-service/train_logistics.py`](https://github.com/darshanafk123/employee-attrition/blob/main/python-service/train_logistics.py) (Model training), [`springboot-service/src/main/java/com/attrition/service/PredictionService.java`](https://github.com/darshanafk123/employee-attrition/blob/main/springboot-service/src/main/java/com/attrition/service/PredictionService.java) (Upstream client)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_api["Public API"]
  node_spring_api["Prediction endpoint"]
  node_employee_input["Input validation<br/>[EmployeeInput.java]"]
  node_spring_errors["Error responses"]
  node_prediction_service["Upstream client"]
end

subgraph group_ml["ML Prediction"]
  node_flask_api["Prediction and health API<br/>[app.py]"]
  node_input_checks["Input checks<br/>[app.py]"]
  node_profile_builder["Profile derivation<br/>[app.py]"]
  node_inference["Model inference<br/>[app.py]"]
  node_model_artifacts["Model and scaler"]
end

subgraph group_training["Model Training"]
  node_training["Model training<br/>[train_logistics.py]"]
  node_training_data["Training dataset"]
  node_scaler_artifact["Scaler artifact<br/>[data_scaler.pkl]"]
end

subgraph group_support["Service Support"]
  node_cors["Browser CORS<br/>[CorsConfig.java]"]
  node_frontend["Frontend entry<br/>[index.html]"]
end

node_caller(("API caller"))

node_caller -->|"submits prediction"| node_spring_api
node_spring_api -->|"validates input"| node_employee_input
node_spring_api -->|"requests prediction"| node_prediction_service
node_prediction_service -->|"posts employee data"| node_flask_api
node_flask_api -->|"checks request"| node_input_checks
node_flask_api -->|"derives profile"| node_profile_builder
node_flask_api -->|"runs prediction"| node_inference
node_inference -->|"loads model"| node_model_artifacts
node_training -->|"reads dataset"| node_training_data
node_training -->|"writes model"| node_model_artifacts
node_training -->|"writes scaler"| node_scaler_artifact
node_inference -->|"uses scaler"| node_scaler_artifact
node_spring_api -->|"routes exceptions"| node_spring_errors
node_frontend -.->|"browser requests"| node_spring_api
node_cors -->|"allows browser requests"| node_spring_api

click node_spring_api "https://github.com/darshanafk123/employee-attrition/blob/main/springboot-service/src/main/java/com/attrition/controller/PredictionController.java"
click node_employee_input "https://github.com/darshanafk123/employee-attrition/blob/main/springboot-service/src/main/java/com/attrition/dto/EmployeeInput.java"
click node_spring_errors "https://github.com/darshanafk123/employee-attrition/blob/main/springboot-service/src/main/java/com/attrition/exception/GlobalExceptionHandler.java"
click node_prediction_service "https://github.com/darshanafk123/employee-attrition/blob/main/springboot-service/src/main/java/com/attrition/service/PredictionService.java"
click node_flask_api "https://github.com/darshanafk123/employee-attrition/blob/main/python-service/app.py"
click node_input_checks "https://github.com/darshanafk123/employee-attrition/blob/main/python-service/app.py"
click node_profile_builder "https://github.com/darshanafk123/employee-attrition/blob/main/python-service/app.py"
click node_inference "https://github.com/darshanafk123/employee-attrition/blob/main/python-service/app.py"
click node_model_artifacts "https://github.com/darshanafk123/employee-attrition/blob/main/python-service/attrition_logistic_model.pkl"
click node_training "https://github.com/darshanafk123/employee-attrition/blob/main/python-service/train_logistics.py"
click node_scaler_artifact "https://github.com/darshanafk123/employee-attrition/blob/main/python-service/data_scaler.pkl"
click node_cors "https://github.com/darshanafk123/employee-attrition/blob/main/springboot-service/src/main/java/com/attrition/config/CorsConfig.java"
click node_frontend "https://github.com/darshanafk123/employee-attrition/blob/main/frontend/index.html"

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_spring_api,node_employee_input,node_spring_errors,node_prediction_service toneBlue
class node_flask_api,node_input_checks,node_profile_builder,node_inference,node_model_artifacts toneAmber
class node_training,node_training_data,node_scaler_artifact,node_caller toneMint
class node_cors,node_frontend toneRose
```

## Components

### Public API

- [Prediction endpoint](https://github.com/darshanafk123/employee-attrition/blob/main/springboot-service/src/main/java/com/attrition/controller/PredictionController.java): `springboot-service/src/main/java/com/attrition/controller/PredictionController.java`
- [Input validation](https://github.com/darshanafk123/employee-attrition/blob/main/springboot-service/src/main/java/com/attrition/dto/EmployeeInput.java): `springboot-service/src/main/java/com/attrition/dto/EmployeeInput.java`
- [Error responses](https://github.com/darshanafk123/employee-attrition/blob/main/springboot-service/src/main/java/com/attrition/exception/GlobalExceptionHandler.java): `springboot-service/src/main/java/com/attrition/exception/GlobalExceptionHandler.java`
- [Upstream client](https://github.com/darshanafk123/employee-attrition/blob/main/springboot-service/src/main/java/com/attrition/service/PredictionService.java): `springboot-service/src/main/java/com/attrition/service/PredictionService.java`

### ML Prediction

- [Prediction and health API](https://github.com/darshanafk123/employee-attrition/blob/main/python-service/app.py): `python-service/app.py`
- [Input checks](https://github.com/darshanafk123/employee-attrition/blob/main/python-service/app.py): `python-service/app.py`
- [Profile derivation](https://github.com/darshanafk123/employee-attrition/blob/main/python-service/app.py): `python-service/app.py`
- [Model inference](https://github.com/darshanafk123/employee-attrition/blob/main/python-service/app.py): `python-service/app.py`
- [Model and scaler](https://github.com/darshanafk123/employee-attrition/blob/main/python-service/attrition_logistic_model.pkl): `python-service/attrition_logistic_model.pkl`

### Model Training

- [Model training](https://github.com/darshanafk123/employee-attrition/blob/main/python-service/train_logistics.py): `python-service/train_logistics.py`
- **Training dataset**
- [Scaler artifact](https://github.com/darshanafk123/employee-attrition/blob/main/python-service/data_scaler.pkl): `python-service/data_scaler.pkl`

### Service Support

- [Browser CORS](https://github.com/darshanafk123/employee-attrition/blob/main/springboot-service/src/main/java/com/attrition/config/CorsConfig.java): `springboot-service/src/main/java/com/attrition/config/CorsConfig.java`
- [Frontend entry](https://github.com/darshanafk123/employee-attrition/blob/main/frontend/index.html): `frontend/index.html`

### Other components

- **API caller**

## Connections

- API caller → Prediction endpoint: submits prediction (evidence: `README.md`)
- Prediction endpoint → Input validation: validates input (evidence: `springboot-service/src/main/java/com/attrition/controller/PredictionController.java`)
- Prediction endpoint → Upstream client: requests prediction (evidence: `springboot-service/src/main/java/com/attrition/controller/PredictionController.java`)
- Upstream client → Prediction and health API: posts employee data (evidence: `springboot-service/src/main/java/com/attrition/service/PredictionService.java`)
- Prediction and health API → Input checks: checks request (evidence: `python-service/app.py`)
- Prediction and health API → Profile derivation: derives profile (evidence: `python-service/app.py`)
- Prediction and health API → Model inference: runs prediction (evidence: `python-service/app.py`)
- Model inference → Model and scaler: loads model (evidence: `python-service/app.py`)
- Model training → Training dataset: reads dataset (evidence: `python-service/train_logistics.py`)
- Model training → Model and scaler: writes model (evidence: `python-service/train_logistics.py`)
- Model training → Scaler artifact: writes scaler (evidence: `python-service/train_logistics.py`)
- Model inference → Scaler artifact: uses scaler (evidence: `python-service/app.py`)
- Prediction endpoint → Error responses: routes exceptions (evidence: `springboot-service/src/main/java/com/attrition/controller/PredictionController.java`)
- Frontend entry → Prediction endpoint: browser requests (evidence: `README.md`)
- Browser CORS → Prediction endpoint: allows browser requests (evidence: `springboot-service/src/main/java/com/attrition/config/CorsConfig.java`)
