# hariss402/credit-card-fraud-detection architecture

> Architecture diagram of the GitHub repository hariss402/credit-card-fraud-detection, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-07-18). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/hariss402/credit-card-fraud-detection
- Repository: https://github.com/hariss402/credit-card-fraud-detection

## Overview

#### 1. Purpose and Execution Model
This is an educational, notebook-driven machine-learning experiment for binary credit-card fraud classification under extreme class imbalance. The primary and apparent sole execution entry point is `Credit_Card_Fraud_Detection.ipynb`; there is no packaged application, service, CLI, deployment artifact, or production inference endpoint.

#### 2. Data Boundary
The workflow consumes the Kaggle Credit Card Fraud Detection dataset, expected under the repository’s data area. Input consists of numerical transaction features—anonymized PCA fields plus `Time` and `Amount`—and a binary `Class` label. The dataset itself is not represented in the supplied tree; its local-data guidance is in `data/readme.md`. The notebook owns loading, inspection, cleaning, and conversion into model-ready feature/target partitions.

Grounding paths:
- `data/`
- `data/readme.md`
- `Credit_Card_Fraud_Detection.ipynb`

#### 3. Exploratory and Preprocessing Stage
The notebook first performs data exploration and EDA to establish class distribution, feature behavior, correlations, and potential outliers. Preprocessing includes feature scaling and outlier detection/removal. Dimensionality reduction with t-SNE is used for exploratory visualization rather than described as a serving-time feature pipeline.

This boundary is important: preprocessing, exploration, visualization, and modeling are coupled in one stateful notebook rather than exported reusable modules.

Grounding path:
- `Credit_Card_Fraud_Detection.ipynb`

#### 4. Imbalance-Handling Branches
The central experimental design compares approaches for the minority fraud class: random under-sampling of legitimate transactions and SMOTE synthetic over-sampling. These sampled datasets feed downstream training/evaluation, enabling comparison against the severe native class distribution.

Sampling must conceptually occur within the training workflow to avoid leakage into held-out evaluation; the repository exposes no standalone pipeline enforcing that separation.

Grounding path:
- `Credit_Card_Fraud_Detection.ipynb`

#### 5. Model Training Layer
The notebook trains several classifier families against the prepared/sampled data:
- Logistic Regression
- K-Nearest Neighbors
- Support Vector Machine
- Decision Tree
- TensorFlow/Keras neural network

Classical estimators are supplied by scikit-learn; the neural-network branch introduces the TensorFlow/Keras runtime. Model comparison is the system’s main output, rather than a selected serialized champion model.

Grounding paths:
- `Credit_Card_Fraud_Detection.ipynb`
- `requirements.txt`

#### 6. Evaluation and Decision Outputs
Trained models are evaluated through accuracy, precision, recall, F1, ROC-AUC, confusion matrices, and precision-recall curves. The project explicitly prioritizes fraud-sensitive measures—especially precision, recall, F1, and ROC-AUC—over raw accuracy. Results are notebook visualizations and analysis, with no indicated artifact registry, model persistence, threshold-serving contract, or automated report.

Grounding path:
- `Credit_Card_Fraud_Detection.ipynb`

#### 7. Runtime and Infrastructure
The runtime is local Python/Jupyter, with notebook dependencies declared in `requirements.txt`; development-specific dependencies are separated in `requirements_dev.txt`. Core libraries are Pandas/NumPy for data handling, Matplotlib/Seaborn for visualization, scikit-learn and imbalanced-learn for classical ML/sampling, and TensorFlow/Keras for neural models. Kaggle is the external dataset source. No cloud infrastructure, database, API, scheduler, CI pipeline, or web framework is present.

Grounding paths:
- `requirements.txt`
- `requirements_dev.txt`
- `Credit_Card_Fraud_Detection.ipynb`

Main entry points: [`Credit_Card_Fraud_Detection.ipynb`](https://github.com/hariss402/credit-card-fraud-detection/blob/main/Credit_Card_Fraud_Detection.ipynb) (Load and partition data), [`data`](https://github.com/hariss402/credit-card-fraud-detection/tree/main/data) (Local data area), [`requirements.txt`](https://github.com/hariss402/credit-card-fraud-detection/blob/main/requirements.txt) (Runtime dependencies), [`requirements_dev.txt`](https://github.com/hariss402/credit-card-fraud-detection/blob/main/requirements_dev.txt) (Development dependencies)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_runtime["Local experiment runtime"]
  node_requirements["Runtime dependencies<br/>dependency manifest<br/>[requirements.txt]"]
  node_dev_requirements["Development dependencies<br/>dependency manifest"]
  node_jupyter{{"Local Python/Jupyter<br/>runtime"}}
end

subgraph group_notebook["Notebook experiment"]
  node_notebook_entry["Fraud detection notebook<br/>execution entry point"]
  node_load_partition["Load and partition data<br/>notebook stage"]
  node_eda["EDA and visualization<br/>notebook stage"]
  node_preprocess["Scale and clean features<br/>notebook stage"]
  node_tsne["t-SNE visualization<br/>exploratory analysis"]
  node_undersampling["Random undersampling<br/>imbalance branch"]
  node_smote["SMOTE oversampling<br/>imbalance branch"]
  node_evaluation["Fraud-focused evaluation<br/>notebook stage"]
  node_results["Comparison plots and analysis<br/>experiment output"]
end

subgraph group_models["Model branches"]
  node_classical_models["Classical classifiers<br/>scikit-learn models"]
  node_neural_model["Keras neural network<br/>TensorFlow model"]
end

node_kaggle[("Kaggle fraud dataset<br/>external dataset")]
node_data_area[("Local data area<br/>data boundary")]
node_data_readme["Data setup guidance<br/>documentation<br/>[readme.md]"]

node_kaggle -.->|"downloaded locally"| node_data_area
node_data_readme -.->|"documents setup"| node_data_area
node_requirements -.->|"installs runtime"| node_jupyter
node_dev_requirements -.->|"adds dev tooling"| node_jupyter
node_jupyter -->|"executes"| node_notebook_entry
node_data_area -->|"transaction data"| node_load_partition
node_notebook_entry -->|"loads"| node_load_partition
node_load_partition -->|"inspect data"| node_eda
node_load_partition -->|"features and target"| node_preprocess
node_preprocess -->|"visualize structure"| node_tsne
node_preprocess -->|"training data"| node_undersampling
node_preprocess -->|"training data"| node_smote
node_undersampling -->|"sampled training set"| node_classical_models
node_smote -->|"sampled training set"| node_classical_models
node_undersampling -->|"sampled training set"| node_neural_model
node_smote -->|"sampled training set"| node_neural_model
node_classical_models -->|"predictions"| node_evaluation
node_neural_model -->|"predictions"| node_evaluation
node_load_partition -->|"held-out evaluation data"| node_evaluation
node_evaluation -->|"metrics and plots"| node_results

click node_data_area "https://github.com/hariss402/credit-card-fraud-detection/tree/main/data"
click node_data_readme "https://github.com/hariss402/credit-card-fraud-detection/blob/main/data/readme.md"
click node_requirements "https://github.com/hariss402/credit-card-fraud-detection/blob/main/requirements.txt"
click node_dev_requirements "https://github.com/hariss402/credit-card-fraud-detection/blob/main/requirements_dev.txt"
click node_notebook_entry "https://github.com/hariss402/credit-card-fraud-detection/blob/main/Credit_Card_Fraud_Detection.ipynb"
click node_load_partition "https://github.com/hariss402/credit-card-fraud-detection/blob/main/Credit_Card_Fraud_Detection.ipynb"
click node_eda "https://github.com/hariss402/credit-card-fraud-detection/blob/main/Credit_Card_Fraud_Detection.ipynb"
click node_preprocess "https://github.com/hariss402/credit-card-fraud-detection/blob/main/Credit_Card_Fraud_Detection.ipynb"
click node_tsne "https://github.com/hariss402/credit-card-fraud-detection/blob/main/Credit_Card_Fraud_Detection.ipynb"
click node_undersampling "https://github.com/hariss402/credit-card-fraud-detection/blob/main/Credit_Card_Fraud_Detection.ipynb"
click node_smote "https://github.com/hariss402/credit-card-fraud-detection/blob/main/Credit_Card_Fraud_Detection.ipynb"
click node_classical_models "https://github.com/hariss402/credit-card-fraud-detection/blob/main/Credit_Card_Fraud_Detection.ipynb"
click node_neural_model "https://github.com/hariss402/credit-card-fraud-detection/blob/main/Credit_Card_Fraud_Detection.ipynb"
click node_evaluation "https://github.com/hariss402/credit-card-fraud-detection/blob/main/Credit_Card_Fraud_Detection.ipynb"
click node_results "https://github.com/hariss402/credit-card-fraud-detection/blob/main/Credit_Card_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_requirements,node_dev_requirements,node_jupyter toneBlue
class node_notebook_entry,node_load_partition,node_eda,node_preprocess,node_tsne,node_undersampling,node_smote,node_evaluation,node_results toneAmber
class node_classical_models,node_neural_model toneMint
class node_kaggle,node_data_area,node_data_readme toneNeutral
```

## Components

### Local experiment runtime

Stateful Python/Jupyter workflow.

- [Runtime dependencies](https://github.com/hariss402/credit-card-fraud-detection/blob/main/requirements.txt): dependency manifest · ML, visualization, and notebook libraries. · `requirements.txt`
- [Development dependencies](https://github.com/hariss402/credit-card-fraud-detection/blob/main/requirements_dev.txt): dependency manifest · Separate development-only dependencies. · `requirements_dev.txt`
- **Local Python/Jupyter**: runtime · Interactive execution environment.

### Notebook experiment

Exploration, preprocessing, training, and analysis are coupled.

- [Fraud detection notebook](https://github.com/hariss402/credit-card-fraud-detection/blob/main/Credit_Card_Fraud_Detection.ipynb): execution entry point · Sole experiment entry point. · `Credit_Card_Fraud_Detection.ipynb`
- [Load and partition data](https://github.com/hariss402/credit-card-fraud-detection/blob/main/Credit_Card_Fraud_Detection.ipynb): notebook stage · Creates model-ready features, target, and held-out evaluation data. · `Credit_Card_Fraud_Detection.ipynb`
- [EDA and visualization](https://github.com/hariss402/credit-card-fraud-detection/blob/main/Credit_Card_Fraud_Detection.ipynb): notebook stage · Inspects class imbalance, correlations, features, and outliers. · `Credit_Card_Fraud_Detection.ipynb`
- [Scale and clean features](https://github.com/hariss402/credit-card-fraud-detection/blob/main/Credit_Card_Fraud_Detection.ipynb): notebook stage · Applies scaling and outlier handling. · `Credit_Card_Fraud_Detection.ipynb`
- [t-SNE visualization](https://github.com/hariss402/credit-card-fraud-detection/blob/main/Credit_Card_Fraud_Detection.ipynb): exploratory analysis · Dimensionality reduction for visualization, not serving features. · `Credit_Card_Fraud_Detection.ipynb`
- [Random undersampling](https://github.com/hariss402/credit-card-fraud-detection/blob/main/Credit_Card_Fraud_Detection.ipynb): imbalance branch · Reduces legitimate-class training examples. · `Credit_Card_Fraud_Detection.ipynb`
- [SMOTE oversampling](https://github.com/hariss402/credit-card-fraud-detection/blob/main/Credit_Card_Fraud_Detection.ipynb): imbalance branch · Synthesizes minority-class training examples. · `Credit_Card_Fraud_Detection.ipynb`
- [Fraud-focused evaluation](https://github.com/hariss402/credit-card-fraud-detection/blob/main/Credit_Card_Fraud_Detection.ipynb): notebook stage · Computes precision, recall, F1, ROC-AUC, accuracy, and confusion matrices. · `Credit_Card_Fraud_Detection.ipynb`
- [Comparison plots and analysis](https://github.com/hariss402/credit-card-fraud-detection/blob/main/Credit_Card_Fraud_Detection.ipynb): experiment output · Notebook-only model comparison; no persisted champion model. · `Credit_Card_Fraud_Detection.ipynb`

### Model branches

Classifier families compared in the notebook.

- [Classical classifiers](https://github.com/hariss402/credit-card-fraud-detection/blob/main/Credit_Card_Fraud_Detection.ipynb): scikit-learn models · Logistic regression, KNN, SVM, and decision tree. · `Credit_Card_Fraud_Detection.ipynb`
- [Keras neural network](https://github.com/hariss402/credit-card-fraud-detection/blob/main/Credit_Card_Fraud_Detection.ipynb): TensorFlow model · Neural classifier branch. · `Credit_Card_Fraud_Detection.ipynb`

### Other components

- **Kaggle fraud dataset**: external dataset · Credit-card transactions with numerical features and Class label.
- [Local data area](https://github.com/hariss402/credit-card-fraud-detection/tree/main/data): data boundary · Expected local location for the downloaded dataset. · `data`
- [Data setup guidance](https://github.com/hariss402/credit-card-fraud-detection/blob/main/data/readme.md): documentation · Explains local dataset placement. · `data/readme.md`

## Connections

- Kaggle fraud dataset → Local data area: downloaded locally
- Data setup guidance → Local data area: documents setup
- Runtime dependencies → Local Python/Jupyter: installs runtime
- Development dependencies → Local Python/Jupyter: adds dev tooling
- Local Python/Jupyter → Fraud detection notebook: executes
- Local data area → Load and partition data: transaction data
- Fraud detection notebook → Load and partition data: loads
- Load and partition data → EDA and visualization: inspect data
- Load and partition data → Scale and clean features: features and target
- Scale and clean features → t-SNE visualization: visualize structure
- Scale and clean features → Random undersampling: training data
- Scale and clean features → SMOTE oversampling: training data
- Random undersampling → Classical classifiers: sampled training set
- SMOTE oversampling → Classical classifiers: sampled training set
- Random undersampling → Keras neural network: sampled training set
- SMOTE oversampling → Keras neural network: sampled training set
- Classical classifiers → Fraud-focused evaluation: predictions
- Keras neural network → Fraud-focused evaluation: predictions
- Load and partition data → Fraud-focused evaluation: held-out evaluation data
- Fraud-focused evaluation → Comparison plots and analysis: metrics and plots
