About Project

Real-Time Financial Fraud Detection System using Machine Learning

Purpose

Banks lose large sums to fraudulent transactions every year. This project shows how a machine-learning model can score each transaction the moment it arrives, flag suspicious ones, explain why, and raise alerts for a fraud analyst to review.

It performs real-time inference: every transaction is predicted instantly. The transaction stream itself is simulated for demonstration.

How it works

  1. generate_dataset.py creates about 20,000 synthetic transactions (4% fraud).
  2. train_model.py cleans the data, trains Logistic Regression and Random Forest inside a scikit-learn Pipeline, and saves the best one.
  3. app.py (Flask) loads the pipeline once and exposes a REST API.
  4. The browser sends a transaction to POST /api/predict and gets the prediction, probability, risk level and reasons.
  5. Results are stored in SQLite; high-risk transactions create fraud alerts.

3-tier architecture

PresentationHTML, CSS, JS, Bootstrap, Chart.js
ApplicationFlask API + ML pipeline
DataSQLite database

Technologies

  • PythonCore language
  • FlaskWeb server and REST API
  • pandas / NumPyData handling and generation
  • scikit-learnModels, pipeline and metrics
  • joblibSaves the trained pipeline
  • SQLiteFile-based database
  • Bootstrap 5Responsive styling
  • Chart.jsDashboard charts

Risk levels

  • Low probability below 30%
  • Medium 30–70%
  • High 70% and above (creates an alert)

Disclaimer

This is an academic prototype built with synthetic data. It is not connected to any real bank, card network or payment system, and never collects card numbers, CVVs, passwords or personal data.