A production-style, real-time fraud detection system built end to end — from streaming ingestion to an ML scorer to a live dashboard, deployed on Kubernetes with GitOps.
Credit-card fraud is rare and highly imbalanced — under 0.2% of transactions in the public Kaggle Credit Card Fraud dataset are fraudulent. Rather than train on scarce labels, this system uses an unsupervised anomaly detector (Isolation Forest) that learns what "normal" spending looks like and flags outliers in real time.
A producer replays held-out transactions into a Kafka topic. The scoring service consumes them, runs the model, and publishes risk scores to a second topic. The query API (FastAPI) persists results to Postgres and pushes aggregated metrics to the dashboard over Server-Sent Events every 200 ms — live rate, latency p95, risk distribution and fraud flags.
transactions.raw at a configurable rate; exposes a small HTTP control endpoint to pause/resume the streamtransactions.raw + a priority transactions.manual topic, scores each transaction with the Isolation Forest, publishes to transactions.scored; exports Prometheus metrics on its own port/metrics for request rate/latency/errors, and hosts the static landing/demo pagesRobustScaler on Time/Amount, fit on normal-only rows to avoid label leakageterraform plan stays clean