Fraud Detection Project is a full-stack machine learning application for credit card fraud prediction. It combines a Flask API, a React dashboard, and an ensemble-based training pipeline to score transactions as Legitimate, Suspicious, or Fraud.
Suggested GitHub repository description:
Full-stack credit card fraud detection app with Flask, React, ensemble ML models, Docker support, and GitHub Actions CI.
Suggested Docker Hub short description:
Full-stack fraud detection app with a Flask API, React frontend, and ensemble machine learning pipeline.
Suggested GitHub topics:
fraud-detection machine-learning flask react docker xgboost lightgbm scikit-learn api fintech
- Fraud probability output and human-readable fraud decision
- Risk score from
0to100 - Weighted ensemble of
RandomForest,XGBoost,LightGBM, optionalCatBoost, andIsolationForest - Feature engineering and dynamic thresholding
- Flask API for integration and automation
- React frontend for interactive testing
- Docker image and Compose support
- GitHub Actions workflows for CI and container publishing
.
+-- app.py
+-- train_pipeline.py
+-- prepare_dataset.py
+-- requirements.txt
+-- Dockerfile
+-- compose.yaml
+-- src/
| +-- features.py
+-- frontend/
+-- data/
| +-- cleaned_data.csv
+-- model/
+-- tests/
+-- .github/workflows/ci.yml
+-- .github/workflows/docker-publish.yml
The training pipeline expects data/cleaned_data.csv.
Required columns:
TimeV1toV28AmountClasssource
Training uses records where source == "creditcard".
To prepare a compatible dataset from a standard fraud CSV:
python prepare_dataset.py path/to/creditcard.csvIf you already have a compatible file, place it directly at data/cleaned_data.csv.
Install backend dependencies:
pip install -r requirements.txtWindows fallback:
.\Scripts\python.exe -m pip install -r requirements.txtInstall frontend dependencies:
cd frontend
npm ciTrain the ensemble pipeline:
python train_pipeline.pyEnable SMOTE on Windows:
$env:USE_SMOTE=1
python train_pipeline.pyOptional CatBoost support:
pip install catboostArtifacts are saved to model/.
Start the Flask app:
python app.pyWindows helpers:
.\run.ps1run.batOpen:
http://localhost:5000http://localhost:5000/health
For frontend development:
cd frontend
npm run devThen open http://localhost:5173.
Health endpoints:
GET /healthGET /apiGET /api/health
Prediction endpoints:
POST /predictPOST /api/predict
Required JSON fields:
TimeV1toV28Amount
Example response:
{
"risk_score": 17,
"fraud_probability": 0.17,
"threshold_used": 0.57,
"prediction": 0,
"final_decision": "Legitimate",
"model": "weighted_ensemble"
}Build the image locally:
docker build -t fraud-detection-app .Run the container:
docker run --rm -p 5000:5000 fraud-detection-appOr use Docker Compose:
docker compose up --buildApp URLs:
http://localhost:5000http://localhost:5000/healthhttp://localhost:5000/api
The image build:
- installs Python dependencies
- builds the React frontend
- serves the built frontend through Flask
- exposes port
5000
This repository now includes .github/workflows/docker-publish.yml for publishing an image to Docker Hub from GitHub Actions.
Public image:
n8nproject2026/fraud-detection-project:latest
Docker Hub:
https://hub.docker.com/r/n8nproject2026/fraud-detection-project
Before it can push images, add these repository secrets in GitHub:
DOCKERHUB_USERNAMEDOCKERHUB_TOKEN
The workflow is already configured to publish n8nproject2026/fraud-detection-project. After the secrets are added, pushes to main and version tags such as v1.0.0 can publish ready-to-run images automatically.
The repository includes:
.github/workflows/ci.ymlfor backend smoke tests and frontend build validation.github/workflows/docker-publish.ymlfor container image publishing
Backend tests:
python -m unittest discover -s tests -vFrontend production build:
cd frontend
npm run builddata/cleaned_data.csvis intentionally not committed- files in
model/are generated after training - prediction requests return
503if no trained model artifacts are available