# vajihvu/insurance-fraud-detection architecture

> Architecture diagram of the GitHub repository vajihvu/insurance-fraud-detection, 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/vajihvu/insurance-fraud-detection
- Repository: https://github.com/vajihvu/insurance-fraud-detection

## Overview

This repository is a command-line insurance-fraud model training and evaluation pipeline, with a notebook for interactive analysis. Its main workflow loads a CSV, prepares and splits claim data, optionally applies SMOTE, trains XGBoost and LightGBM, saves artifacts, and evaluates both models. An optional SHAP branch explains XGBoost predictions. The source excerpts show the CLI’s orchestration and core modules; the notebook and utility implementation were not sampled, so their internal behavior is not detailed.

Main entry points: [`main.py`](https://github.com/vajihvu/insurance-fraud-detection/blob/main/main.py) (Pipeline runner), [`data/Worksheet in Case Study question 2.csv`](https://github.com/vajihvu/insurance-fraud-detection/blob/main/data/Worksheet%20in%20Case%20Study%20question%202.csv) (Claims CSV), [`src/data_preprocessing.py`](https://github.com/vajihvu/insurance-fraud-detection/blob/main/src/data_preprocessing.py) (Preprocessing and split), [`src/model_training.py`](https://github.com/vajihvu/insurance-fraud-detection/blob/main/src/model_training.py) (XGBoost training)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_ingest["Data preparation"]
  node_csv["Claims CSV"]
  node_prep["Preprocessing and split"]
end

subgraph group_training["Model training"]
  node_smote["SMOTE resampling<br/>[main.py]"]
  node_xgb["XGBoost training<br/>[model_training.py]"]
  node_lgb["LightGBM training<br/>[model_training.py]"]
  node_artifacts["Saved model artifacts"]
end

subgraph group_assessment["Evaluation and explainability"]
  node_evaluation["Metrics and PR curve<br/>[evaluate.py]"]
  node_shap["SHAP explanation<br/>[main.py]"]
  node_shapplot["SHAP summary plot<br/>[main.py]"]
end

subgraph group_runtime["Pipeline runtime"]
  node_runner["Pipeline runner<br/>[main.py]"]
  node_utils["Run utilities<br/>[utils.py]"]
  node_notebook["Interactive analysis"]
end

node_user(("CLI user"))

node_user -->|"runs"| node_runner
node_runner -->|"loads"| node_csv
node_runner -->|"preprocesses"| node_prep
node_runner -->|"optionally resamples"| node_smote
node_runner -->|"trains"| node_xgb
node_runner -->|"trains"| node_lgb
node_runner -->|"saves models and preprocessor"| node_artifacts
node_runner -->|"evaluates"| node_evaluation
node_runner -->|"optionally explains"| node_shap
node_shap -->|"writes plot"| node_shapplot
node_runner -->|"uses run helpers"| node_utils
node_user -->|"opens for analysis"| node_notebook

click node_runner "https://github.com/vajihvu/insurance-fraud-detection/blob/main/main.py"
click node_csv "https://github.com/vajihvu/insurance-fraud-detection/blob/main/data/Worksheet%20in%20Case%20Study%20question%202.csv"
click node_prep "https://github.com/vajihvu/insurance-fraud-detection/blob/main/src/data_preprocessing.py"
click node_smote "https://github.com/vajihvu/insurance-fraud-detection/blob/main/main.py"
click node_xgb "https://github.com/vajihvu/insurance-fraud-detection/blob/main/src/model_training.py"
click node_lgb "https://github.com/vajihvu/insurance-fraud-detection/blob/main/src/model_training.py"
click node_artifacts "https://github.com/vajihvu/insurance-fraud-detection/tree/main/model"
click node_evaluation "https://github.com/vajihvu/insurance-fraud-detection/blob/main/src/evaluate.py"
click node_shap "https://github.com/vajihvu/insurance-fraud-detection/blob/main/main.py"
click node_shapplot "https://github.com/vajihvu/insurance-fraud-detection/blob/main/main.py"
click node_utils "https://github.com/vajihvu/insurance-fraud-detection/blob/main/src/utils.py"
click node_notebook "https://github.com/vajihvu/insurance-fraud-detection/blob/main/insurance_fraud_detection.ipynb"

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_csv,node_prep,node_user toneBlue
class node_smote,node_xgb,node_lgb,node_artifacts toneAmber
class node_evaluation,node_shap,node_shapplot toneMint
class node_runner,node_utils,node_notebook toneRose
```

## Components

### Data preparation

- [Claims CSV](https://github.com/vajihvu/insurance-fraud-detection/blob/main/data/Worksheet%20in%20Case%20Study%20question%202.csv): `data/Worksheet in Case Study question 2.csv`
- [Preprocessing and split](https://github.com/vajihvu/insurance-fraud-detection/blob/main/src/data_preprocessing.py): `src/data_preprocessing.py`

### Model training

- [SMOTE resampling](https://github.com/vajihvu/insurance-fraud-detection/blob/main/main.py): `main.py`
- [XGBoost training](https://github.com/vajihvu/insurance-fraud-detection/blob/main/src/model_training.py): `src/model_training.py`
- [LightGBM training](https://github.com/vajihvu/insurance-fraud-detection/blob/main/src/model_training.py): `src/model_training.py`
- [Saved model artifacts](https://github.com/vajihvu/insurance-fraud-detection/tree/main/model): `model`

### Evaluation and explainability

- [Metrics and PR curve](https://github.com/vajihvu/insurance-fraud-detection/blob/main/src/evaluate.py): `src/evaluate.py`
- [SHAP explanation](https://github.com/vajihvu/insurance-fraud-detection/blob/main/main.py): `main.py`
- [SHAP summary plot](https://github.com/vajihvu/insurance-fraud-detection/blob/main/main.py): `main.py`

### Pipeline runtime

- [Pipeline runner](https://github.com/vajihvu/insurance-fraud-detection/blob/main/main.py): `main.py`
- [Run utilities](https://github.com/vajihvu/insurance-fraud-detection/blob/main/src/utils.py): `src/utils.py`
- [Interactive analysis](https://github.com/vajihvu/insurance-fraud-detection/blob/main/insurance_fraud_detection.ipynb): `insurance_fraud_detection.ipynb`

### Other components

- **CLI user**

## Connections

- CLI user → Pipeline runner: runs (evidence: `README.md`)
- Pipeline runner → Claims CSV: loads (evidence: `main.py`)
- Pipeline runner → Preprocessing and split: preprocesses (evidence: `main.py`)
- Pipeline runner → SMOTE resampling: optionally resamples (evidence: `main.py`)
- Pipeline runner → XGBoost training: trains (evidence: `main.py`)
- Pipeline runner → LightGBM training: trains (evidence: `main.py`)
- Pipeline runner → Saved model artifacts: saves models and preprocessor (evidence: `main.py`)
- Pipeline runner → Metrics and PR curve: evaluates (evidence: `main.py`)
- Pipeline runner → SHAP explanation: optionally explains (evidence: `main.py`)
- SHAP explanation → SHAP summary plot: writes plot (evidence: `main.py`)
- Pipeline runner → Run utilities: uses run helpers (evidence: `main.py`)
- CLI user → Interactive analysis: opens for analysis (evidence: `README.md`)
