# clive0707/banking-fraud-analytics architecture

> Architecture diagram of the GitHub repository clive0707/banking-fraud-analytics, 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/clive0707/banking-fraud-analytics
- Repository: https://github.com/clive0707/banking-fraud-analytics

## Overview

This is a banking-transaction analytics product: transaction data is cleaned and aggregated, then used for supervised fraud modeling, customer segmentation, and anomaly detection; Flask serves those results to a dashboard and accepts live prediction requests. The sampled source supports the preprocessing, segmentation, anomaly, API, and prediction links shown. Several dashboard and API capabilities are documented but their internal wiring was not fully sampled, so they are represented at the documented subsystem level.

Main entry points: [`data/processed`](https://github.com/clive0707/banking-fraud-analytics/tree/main/data/processed) (Processed data and metrics), [`backend/services/data_service.py`](https://github.com/clive0707/banking-fraud-analytics/blob/main/backend/services/data_service.py) (Data service), [`backend/app.py`](https://github.com/clive0707/banking-fraud-analytics/blob/main/backend/app.py) (Flask application), [`frontend/js/app.js`](https://github.com/clive0707/banking-fraud-analytics/blob/main/frontend/js/app.js) (Analytics dashboard)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_processing["Data processing"]
  node_preprocess["Clean and aggregate<br/>[preprocess.py]"]
  node_processed_data[("Processed data and metrics")]
end

subgraph group_ml["Risk and customer models"]
  node_train["Fraud model training<br/>[train_models.py]"]
  node_fraud_models[("Fraud models")]
  node_segment["Customer segmentation<br/>[clustering.py]"]
  node_cluster_results["Cluster profiles"]
  node_anomaly["Anomaly detection<br/>[anomaly.py]"]
  node_anomaly_results["Anomaly results"]
end

subgraph group_backend["API and serving"]
  node_app["Flask application<br/>[app.py]"]
  node_analytics_routes["Analytics routes"]
  node_prediction_routes["Prediction route"]
  node_service["Data service<br/>[data_service.py]"]
end

subgraph group_ui["Dashboard"]
  node_dashboard["Analytics dashboard<br/>[app.js]"]
end

node_analyst(("Analyst"))
node_raw_data["Transaction data"]

node_raw_data -->|"loads and transforms"| node_preprocess
node_preprocess -->|"writes aggregates and sample"| node_processed_data
node_processed_data -->|"provides training sample"| node_train
node_train -->|"saves models and metrics"| node_fraud_models
node_processed_data -->|"provides customer profiles"| node_segment
node_segment -->|"writes cluster profiles"| node_cluster_results
node_processed_data -->|"provides transaction sample"| node_anomaly
node_anomaly -->|"writes anomaly summary"| node_anomaly_results
node_analyst -->|"uses"| node_dashboard
node_dashboard -->|"requests dashboard"| node_app
node_app -->|"registers routes"| node_analytics_routes
node_app -->|"registers routes"| node_prediction_routes
node_app -->|"initializes"| node_service
node_analytics_routes -->|"requests analytics"| node_service
node_prediction_routes -->|"requests prediction"| node_service
node_service -->|"reads metrics and transactions"| node_processed_data
node_service -->|"loads models for inference"| node_fraud_models
node_dashboard -->|"fetches analytics"| node_analytics_routes
node_dashboard -->|"submits predictions"| node_prediction_routes

click node_preprocess "https://github.com/clive0707/banking-fraud-analytics/blob/main/src/preprocessing/preprocess.py"
click node_processed_data "https://github.com/clive0707/banking-fraud-analytics/tree/main/data/processed"
click node_train "https://github.com/clive0707/banking-fraud-analytics/blob/main/src/fraud_detection/train_models.py"
click node_fraud_models "https://github.com/clive0707/banking-fraud-analytics/tree/main/models"
click node_segment "https://github.com/clive0707/banking-fraud-analytics/blob/main/src/customer_segmentation/clustering.py"
click node_cluster_results "https://github.com/clive0707/banking-fraud-analytics/blob/main/data/processed/customer_clusters.json"
click node_anomaly "https://github.com/clive0707/banking-fraud-analytics/blob/main/src/anomaly_detection/anomaly.py"
click node_anomaly_results "https://github.com/clive0707/banking-fraud-analytics/blob/main/data/processed/anomalies_summary.json"
click node_app "https://github.com/clive0707/banking-fraud-analytics/blob/main/backend/app.py"
click node_analytics_routes "https://github.com/clive0707/banking-fraud-analytics/blob/main/backend/routes/analytics_routes.py"
click node_prediction_routes "https://github.com/clive0707/banking-fraud-analytics/blob/main/backend/routes/prediction_routes.py"
click node_service "https://github.com/clive0707/banking-fraud-analytics/blob/main/backend/services/data_service.py"
click node_dashboard "https://github.com/clive0707/banking-fraud-analytics/blob/main/frontend/js/app.js"

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_preprocess,node_processed_data toneBlue
class node_train,node_fraud_models,node_segment,node_cluster_results,node_anomaly,node_anomaly_results toneAmber
class node_app,node_analytics_routes,node_prediction_routes,node_service toneMint
class node_dashboard toneRose
class node_analyst,node_raw_data toneIndigo
```

## Components

### Data processing

- [Clean and aggregate](https://github.com/clive0707/banking-fraud-analytics/blob/main/src/preprocessing/preprocess.py): `src/preprocessing/preprocess.py`
- [Processed data and metrics](https://github.com/clive0707/banking-fraud-analytics/tree/main/data/processed): `data/processed`

### Risk and customer models

- [Fraud model training](https://github.com/clive0707/banking-fraud-analytics/blob/main/src/fraud_detection/train_models.py): `src/fraud_detection/train_models.py`
- [Fraud models](https://github.com/clive0707/banking-fraud-analytics/tree/main/models): `models`
- [Customer segmentation](https://github.com/clive0707/banking-fraud-analytics/blob/main/src/customer_segmentation/clustering.py): `src/customer_segmentation/clustering.py`
- [Cluster profiles](https://github.com/clive0707/banking-fraud-analytics/blob/main/data/processed/customer_clusters.json): `data/processed/customer_clusters.json`
- [Anomaly detection](https://github.com/clive0707/banking-fraud-analytics/blob/main/src/anomaly_detection/anomaly.py): `src/anomaly_detection/anomaly.py`
- [Anomaly results](https://github.com/clive0707/banking-fraud-analytics/blob/main/data/processed/anomalies_summary.json): `data/processed/anomalies_summary.json`

### API and serving

- [Flask application](https://github.com/clive0707/banking-fraud-analytics/blob/main/backend/app.py): `backend/app.py`
- [Analytics routes](https://github.com/clive0707/banking-fraud-analytics/blob/main/backend/routes/analytics_routes.py): `backend/routes/analytics_routes.py`
- [Prediction route](https://github.com/clive0707/banking-fraud-analytics/blob/main/backend/routes/prediction_routes.py): `backend/routes/prediction_routes.py`
- [Data service](https://github.com/clive0707/banking-fraud-analytics/blob/main/backend/services/data_service.py): `backend/services/data_service.py`

### Dashboard

- [Analytics dashboard](https://github.com/clive0707/banking-fraud-analytics/blob/main/frontend/js/app.js): `frontend/js/app.js`

### Other components

- **Analyst**
- **Transaction data**

## Connections

- Transaction data → Clean and aggregate: loads and transforms
- Clean and aggregate → Processed data and metrics: writes aggregates and sample
- Processed data and metrics → Fraud model training: provides training sample
- Fraud model training → Fraud models: saves models and metrics
- Processed data and metrics → Customer segmentation: provides customer profiles
- Customer segmentation → Cluster profiles: writes cluster profiles
- Processed data and metrics → Anomaly detection: provides transaction sample
- Anomaly detection → Anomaly results: writes anomaly summary
- Analyst → Analytics dashboard: uses
- Analytics dashboard → Flask application: requests dashboard
- Flask application → Analytics routes: registers routes
- Flask application → Prediction route: registers routes
- Flask application → Data service: initializes
- Analytics routes → Data service: requests analytics
- Prediction route → Data service: requests prediction
- Data service → Processed data and metrics: reads metrics and transactions
- Data service → Fraud models: loads models for inference
- Analytics dashboard → Analytics routes: fetches analytics
- Analytics dashboard → Prediction route: submits predictions
