# ukr555/customer_churn_prediction architecture

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

- Interactive diagram: https://gitdiagram.com/ukr555/customer_churn_prediction
- Repository: https://github.com/ukr555/customer_churn_prediction

## Overview

Grocery Customer Churn Prediction is a Spring Boot web app: a retailer enters customer details, the app converts them to a customer record, predicts churn, and displays the prediction and risk category. At startup, the prediction service loads customer data and evaluates several Weka algorithms, selecting the best-performing model. The README also describes personalized retention recommendations; their implementation is not shown in the sampled source, so the result page represents this documented capability. The CSV loader’s exact data access is unsampled, so its dataset link is unverified.

Main entry points: [`src/main/java/com/grocery/churn/controller/ChurnPredictionController.java`](https://github.com/ukr555/customer_churn_prediction/blob/master/src/main/java/com/grocery/churn/controller/ChurnPredictionController.java) (Prediction controller), [`src/main/java/com/grocery/churn/service/ChurnPredictionService.java`](https://github.com/ukr555/customer_churn_prediction/blob/master/src/main/java/com/grocery/churn/service/ChurnPredictionService.java) (Churn prediction service), [`src/main/java/com/grocery/churn/model/PredictionRequest.java`](https://github.com/ukr555/customer_churn_prediction/blob/master/src/main/java/com/grocery/churn/model/PredictionRequest.java) (Prediction request), [`src/main/java/com/grocery/churn/util/CSVDataLoader.java`](https://github.com/ukr555/customer_churn_prediction/blob/master/src/main/java/com/grocery/churn/util/CSVDataLoader.java) (CSV data loader)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_web["Web experience"]
  node_application["Spring Boot app"]
  node_controller["Prediction controller"]
  node_form["Prediction form"]
  node_home["Home and about<br/>[index.html]"]
  node_resultpage["Results and guidance"]
end

subgraph group_domain["Prediction domain"]
  node_request["Prediction request"]
  node_customer["Customer record<br/>[Customer.java]"]
  node_prediction["Prediction result"]
end

subgraph group_learning["Model training"]
  node_service["Churn prediction service"]
  node_loader["CSV data loader<br/>[CSVDataLoader.java]"]
  node_dataset[("Customer dataset")]
  node_evaluation["Model evaluation and selection"]
end

node_retailer(("Retailer"))

node_retailer -->|"submits details"| node_controller
node_controller -->|"serves form"| node_form
node_controller -->|"serves pages"| node_home
node_controller -->|"binds input"| node_request
node_request -->|"converts to"| node_customer
node_controller -->|"requests prediction"| node_service
node_controller -->|"serves results"| node_resultpage
node_service -->|"loads data through"| node_loader
node_loader -.->|"loads from"| node_dataset
node_service -->|"trains and predicts"| node_customer
node_service -->|"evaluates models"| node_evaluation
node_service -->|"returns result"| node_prediction
node_controller -->|"passes result"| node_prediction
node_application -.->|"initializes at startup"| node_service

click node_application "https://github.com/ukr555/customer_churn_prediction/blob/master/src/main/java/com/grocery/churn/GroceryChurnApplication.java"
click node_controller "https://github.com/ukr555/customer_churn_prediction/blob/master/src/main/java/com/grocery/churn/controller/ChurnPredictionController.java"
click node_form "https://github.com/ukr555/customer_churn_prediction/blob/master/src/main/resources/templates/prediction-form.html"
click node_home "https://github.com/ukr555/customer_churn_prediction/blob/master/src/main/resources/templates/index.html"
click node_resultpage "https://github.com/ukr555/customer_churn_prediction/blob/master/src/main/resources/templates/prediction-result.html"
click node_request "https://github.com/ukr555/customer_churn_prediction/blob/master/src/main/java/com/grocery/churn/model/PredictionRequest.java"
click node_customer "https://github.com/ukr555/customer_churn_prediction/blob/master/src/main/java/com/grocery/churn/model/Customer.java"
click node_service "https://github.com/ukr555/customer_churn_prediction/blob/master/src/main/java/com/grocery/churn/service/ChurnPredictionService.java"
click node_loader "https://github.com/ukr555/customer_churn_prediction/blob/master/src/main/java/com/grocery/churn/util/CSVDataLoader.java"
click node_dataset "https://github.com/ukr555/customer_churn_prediction/blob/master/src/main/resources/data/grocery_customers.csv"
click node_evaluation "https://github.com/ukr555/customer_churn_prediction/blob/master/src/main/java/com/grocery/churn/service/ChurnPredictionService.java"
click node_prediction "https://github.com/ukr555/customer_churn_prediction/blob/master/src/main/java/com/grocery/churn/model/PredictionResult.java"

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_application,node_controller,node_form,node_home,node_resultpage toneBlue
class node_request,node_customer,node_prediction toneAmber
class node_service,node_loader,node_dataset,node_evaluation toneMint
class node_retailer toneIndigo
```

## Components

### Web experience

- [Spring Boot app](https://github.com/ukr555/customer_churn_prediction/blob/master/src/main/java/com/grocery/churn/GroceryChurnApplication.java): `src/main/java/com/grocery/churn/GroceryChurnApplication.java`
- [Prediction controller](https://github.com/ukr555/customer_churn_prediction/blob/master/src/main/java/com/grocery/churn/controller/ChurnPredictionController.java): `src/main/java/com/grocery/churn/controller/ChurnPredictionController.java`
- [Prediction form](https://github.com/ukr555/customer_churn_prediction/blob/master/src/main/resources/templates/prediction-form.html): `src/main/resources/templates/prediction-form.html`
- [Home and about](https://github.com/ukr555/customer_churn_prediction/blob/master/src/main/resources/templates/index.html): `src/main/resources/templates/index.html`
- [Results and guidance](https://github.com/ukr555/customer_churn_prediction/blob/master/src/main/resources/templates/prediction-result.html): `src/main/resources/templates/prediction-result.html`

### Prediction domain

- [Prediction request](https://github.com/ukr555/customer_churn_prediction/blob/master/src/main/java/com/grocery/churn/model/PredictionRequest.java): `src/main/java/com/grocery/churn/model/PredictionRequest.java`
- [Customer record](https://github.com/ukr555/customer_churn_prediction/blob/master/src/main/java/com/grocery/churn/model/Customer.java): `src/main/java/com/grocery/churn/model/Customer.java`
- [Prediction result](https://github.com/ukr555/customer_churn_prediction/blob/master/src/main/java/com/grocery/churn/model/PredictionResult.java): `src/main/java/com/grocery/churn/model/PredictionResult.java`

### Model training

- [Churn prediction service](https://github.com/ukr555/customer_churn_prediction/blob/master/src/main/java/com/grocery/churn/service/ChurnPredictionService.java): `src/main/java/com/grocery/churn/service/ChurnPredictionService.java`
- [CSV data loader](https://github.com/ukr555/customer_churn_prediction/blob/master/src/main/java/com/grocery/churn/util/CSVDataLoader.java): `src/main/java/com/grocery/churn/util/CSVDataLoader.java`
- [Customer dataset](https://github.com/ukr555/customer_churn_prediction/blob/master/src/main/resources/data/grocery_customers.csv): `src/main/resources/data/grocery_customers.csv`
- [Model evaluation and selection](https://github.com/ukr555/customer_churn_prediction/blob/master/src/main/java/com/grocery/churn/service/ChurnPredictionService.java): `src/main/java/com/grocery/churn/service/ChurnPredictionService.java`

### Other components

- **Retailer**

## Connections

- Retailer → Prediction controller: submits details (evidence: `src/main/java/com/grocery/churn/controller/ChurnPredictionController.java`)
- Prediction controller → Prediction form: serves form (evidence: `src/main/java/com/grocery/churn/controller/ChurnPredictionController.java`)
- Prediction controller → Home and about: serves pages (evidence: `src/main/java/com/grocery/churn/controller/ChurnPredictionController.java`)
- Prediction controller → Prediction request: binds input (evidence: `src/main/java/com/grocery/churn/controller/ChurnPredictionController.java`)
- Prediction request → Customer record: converts to (evidence: `src/main/java/com/grocery/churn/model/PredictionRequest.java`)
- Prediction controller → Churn prediction service: requests prediction (evidence: `src/main/java/com/grocery/churn/controller/ChurnPredictionController.java`)
- Prediction controller → Results and guidance: serves results (evidence: `src/main/java/com/grocery/churn/controller/ChurnPredictionController.java`)
- Churn prediction service → CSV data loader: loads data through (evidence: `src/main/java/com/grocery/churn/service/ChurnPredictionService.java`)
- CSV data loader → Customer dataset: loads from
- Churn prediction service → Customer record: trains and predicts (evidence: `src/main/java/com/grocery/churn/service/ChurnPredictionService.java`)
- Churn prediction service → Model evaluation and selection: evaluates models (evidence: `src/main/java/com/grocery/churn/service/ChurnPredictionService.java`)
- Churn prediction service → Prediction result: returns result (evidence: `src/main/java/com/grocery/churn/service/ChurnPredictionService.java`)
- Prediction controller → Prediction result: passes result (evidence: `src/main/java/com/grocery/churn/controller/ChurnPredictionController.java`)
- Spring Boot app → Churn prediction service: initializes at startup
