← Back to Projects
ML · Flask REST API · Dual Scoring Engine · Deployed on Render

FraudGuard
Fraud Detection & Risk Scoring

Production-grade ML-powered REST API + Web Dashboard for real-time loan fraud risk assessment. Dual-engine scoring — rule-based + Random Forest — deployed live on Render with TiDB Serverless, processing 31,000+ borrower records.

Python · Flask Random Forest · 88% Accuracy Deployed · Render JWT Auth TiDB Serverless

Project Overview

FraudGuard is a production-grade fraud detection and risk scoring system — combining a rule-based engine and a trained Random Forest ML model into a single, unified REST API. It simulates the real fintech fraud detection pipelines used by banks and lending platforms.

The system is live on Render at loan-fraud-risk.onrender.com — backed by TiDB Serverless cloud MySQL, with 31,686 borrower records processed and classified.

The Problem

Loan default detection is one of the hardest problems in fintech. A single missed high-risk borrower costs banks thousands. Traditional rule-based systems are too rigid; pure ML models lack explainability. FraudGuard solves this with both engines running in parallel — giving risk officers a rule-based score they can interpret, and an ML confidence score they can trust.

Dual Scoring Engine

Every API call to /api/score or /api/ml-score runs both engines simultaneously and returns a combined result:

  • Rule-Based Engine — scores borrowers on 9-point scale across: interest rate, income-to-loan ratio, loan grade, prior default history, and employment stability
  • ML Engine (Random Forest) — trained on 25,348 records, returns Default / No Default prediction with a confidence percentage from predict_proba()
  • Results are colour-coded: Low Risk (green) → Medium Risk (amber) → High Risk (red)
  • ML sidebar always shows live model accuracy: 88% / F1-Score 0.81

ML Model Details

  • Algorithm: Random Forest Classifier (100 trees)
  • Training set: 25,348 records (80% split)
  • Test set: 6,338 records (20% split)
  • Accuracy: 88% — F1-Score: 0.81
  • Features: age, income, employment length, loan amount, interest rate, income ratio
  • Target: loan_status (Default / No Default)
  • Auto-trained on first deployment — model persists on disk

Web Dashboard

  • Login / Register — JWT-secured auth (HS256 tokens)
  • Risk Intelligence Dashboard — live KPI cards (Low: 19,587 / Medium: 10,156 / High: 1,943), bar chart, portfolio donut chart
  • Score a Borrower — input form → dual engine results in real time
  • Borrower History — 31,686 records, filterable by Low / Medium / High risk, searchable by grade

API Architecture

  • 7 REST endpoints — health, register, login, report, history, score, ml-score
  • JWT-protected routes with Bearer token authentication
  • Modular Flask app structure — routes, models, scoring separated
  • Auto data ingestion and model training on cold start
  • Environment-based config — no secrets in code

Deployment

Deployed on Render with TiDB Serverless as the cloud MySQL backend. The Procfile handles auto startup — Flask serves both the REST API and the HTML dashboard from the same app instance. Zero-downtime cold-start recovery with auto model retraining if model file is missing.

Project Screenshots

Risk Intelligence Dashboard
Risk Intelligence Dashboard — 31,686 records, live KPI cards, risk distribution bar chart & portfolio donut
Login / Register
Login / Register — JWT-secured authentication
Low Risk Score
Score Borrower — Low Risk result: 0/9 points, ML: No Default (77% confidence)
Medium Risk Score
Score Borrower — Medium Risk: 4/9 points, ML: Default (57% confidence)
Live on Render
Live deployment on Render — Medium Risk 3/9, ML: Default (53% confidence)
Borrower History
Borrower History — 31,686 records across 634 pages, filterable by Low / Medium / High risk