← All projects

Project 03 · Jan 2026

Fraud Detection.

Sub-30ms risk scoring for UPI-style transactions

High-level architecture

UsersFrontendNode / Express serverData and MLREST + eventstransactionsrecent historypersist + auditPOST /predictFraud analystMonitors, investigatesReact dashboardAlerts, cases, audit trailTransaction simulatorUPI-style trafficFeature builderVelocity, device, locationRisk orchestratorREST + Socket.IORule engine5 rules + score fusionRedisRecent-transaction cacheMongoDBTransactions, risk logs, casesFastAPI ML serviceIsolation Forest + calibrator
PersonService I builtData storeExternal / separate serviceOne deployable unit

Overview

Fraud detection system for UPI-style transactions using a hybrid ML + rule-based engine (Isolation Forest on 9 behavioral features + 5 fraud rules). Delivers sub-30ms end-to-end scoring with real-time dashboard updates via Socket.IO, explains each decision by surfacing key risk factors, and stays reliable through Redis fallback and ML failure recovery.

What I built

  • 01Hybrid engine: Isolation Forest on 9 behavioral features combined with 5 fraud rules
  • 02Sub-30ms end-to-end scoring with live dashboard updates over Socket.IO
  • 03Explainability: key risk factors surfaced for every decision
  • 04Fault tolerance through Redis fallback and ML failure recovery

Deep dive

How it works under the hood

  1. 01

    Behavioral features from recent history

    For every transaction the server builds features from the sender's recent activity: deviation from their average amount, velocity over the last hour and the last day, device mismatch against known devices, and distance from their usual location. Recent transactions are cached in Redis so these lookups do not hit MongoDB on the hot path, which is what keeps end-to-end scoring under 30ms.

  2. 02

    Two signals, one score

    The Python service scores the features with an Isolation Forest anomaly detector, followed by a logistic calibration layer trained on SMOTE-balanced synthetic data to turn anomaly scores into a fraud probability. The Node orchestrator combines that probability with five deterministic fraud rules into a final 0 to 100 risk score, classified as SAFE, SUSPICIOUS or FRAUD. Rules catch known patterns outright; the model catches behaviour that no rule anticipated.

  3. 03

    Degrading without dropping transactions

    If Redis is unavailable the server falls back to in-memory caching. If the ML service fails or times out, scoring continues on rules alone. Neither failure blocks a transaction, and every degraded decision is recorded as such in the risk log, so an analyst reviewing it later can see it was scored in fallback mode.

  4. 04

    Explainability and the analyst workflow

    Each decision writes a risk log with the ML score, the rules that fired, the top contributing factors with baseline versus observed values, and latency. The dashboard receives it over Socket.IO in real time. Flagged transactions become cases that move through open, under review, resolved or false positive, with assignee and notes, which answers the analyst's core question: why was this flagged?