Project Overview
The Problem Statement
Financial institutions lose billions annually to fraudulent payment transactions. Detecting fraud in real time is exceptionally difficult due to extreme class imbalance: legitimate transactions account for 99.8% of volume while fraudulent activities represent less than 0.2%. Standard accuracy metrics are dangerously misleading in this context.
Engineering Motivation
To build an end-to-end machine learning pipeline that establishes explainable baselines, optimizes Precision-Recall curves over raw accuracy, and packages models into ultra-low-latency ONNX microservices for live payment gate integration.
Core Engineering Goals
- Achieve >0.92 Precision-Recall AUC on highly imbalanced financial transaction test benchmarks.
- Deliver sub-5ms model inference latency per transaction to support real-time payment processing.
- Ensure model explainability using SHAP feature importance analysis for audit compliance.
Target Audience
Fintech risk teams, payment processing engineering teams, and machine learning engineers looking for production-ready anomaly detection architectures.
Key Capabilities & Features
Core technical features designed to fulfill project requirements with high reliability and performance.
Imbalanced Data Engine
Combines SMOTE oversampling and adaptive class weighting to prevent models from defaulting to naive majority-class predictions.
ONNX Low-Latency Inference
Exports trained Scikit-Learn and XGBoost models to ONNX runtime format, cutting prediction latency down to sub-3ms.
Live Fraud Stream Dashboard
Pushes real-time transaction risk score alerts to an administrator dashboard via WebSocket streaming whenever risk exceeds 0.85.
Interactive Architecture Explorer
Hover or click on any system layer to inspect data flow topologies, connection pipelines, and security specifications.
Frontend Client Layer
Single-page responsive web client serving UI components, handling optimistic state updates, and streaming live server notifications.
Technology Stack
Purposeful framework selection and technical rationale behind core architecture dependencies.
AI & ML
- Scikit-Learn & XGBoost
Classical ensemble models offering high accuracy with low computational overhead.
- ONNX Runtime
C++ optimized cross-platform execution engine delivering sub-3ms inference.
- SMOTE (Imbalanced-Learn)
Synthesizes minority class fraud samples to balance training distributions.
Backend
- Python 3.12 & FastAPI
Asynchronous Python web framework ideal for serving ML model endpoints.
- Uvicorn ASGI
High-performance async server handling thousands of concurrent requests.
Database
- TimescaleDB
Time-series optimized PostgreSQL extension for transaction audit logs.
- Redis
In-memory caching of velocity features (e.g. 10-minute transaction counts).
DevOps
- Docker & Kubernetes
Containerized deployment with horizontal pod autoscaling under peak loads.
Key Architectural Trade-Off Rationale
Precision-Recall Optimization over Raw Accuracy
Abandoned simple accuracy metrics (which falsely score 99.8% on zero-prediction models) in favor of PR-AUC and F1 optimization.
ONNX Runtime Conversion
Converted Python joblib models to ONNX format, reducing prediction latency from 18ms to 2.4ms per payload.
Classical Ensembles over Deep Learning
Selected XGBoost and Random Forests for their explainability (SHAP values) and lower inference cost.
Development Journey
Systematic engineering progression from initial domain research to production deployment.
Exploratory Data Analysis & Anomaly Benchmarking
Analyzed 284,000 credit card transaction records, mapped PCA features, and evaluated baseline models.
Pipeline & ONNX Architecture Design
Architected SMOTE oversampling pipeline, ONNX runtime conversion specs, and FastAPI service endpoints.
Model Training & FastAPI Service Implementation
Tuned XGBoost hyper-parameters, exported ONNX models, and built the FastAPI inference server with Redis velocity caching.
Latency & Adversarial Robustness Testing
Benchmarked inference speeds under load and tested model resilience against adversarial fraud distribution shifts.
Docker Containerization & Kubernetes Deploy
Packaged FastAPI ONNX microservices into Docker containers deployed to GKE with Prometheus monitoring.
Challenges & Solutions
Deep-dive into non-trivial engineering obstacles, root causes, and verifiable technical outcomes.
Naive SMOTE oversampling caused models to memorize synthetic noise and generate false alarms.
Synthesizing samples without boundary filtering created overlapping decision boundaries between classes.
Applied Borderline-SMOTE combined with Tomek Links cleaning to prune ambiguous synthetic boundary samples.
Performance & Results
Empirical measurements, benchmark results, and production optimization techniques.
Applied Performance Optimization Techniques
- ONNX runtime C++ graph optimization and memory arena allocation.
- Redis in-memory caching of rolling 10-minute customer velocity aggregates.
- Asynchronous Uvicorn ASGI request routing with worker thread pooling.
Lessons Learned
Key engineering insights, architectural reflection, and takeaways for future systems design.
In fraud detection, optimizing for Precision-Recall AUC is vastly superior to raw accuracy or ROC curves.
Model compilation formats like ONNX can reduce inference latency by an order of magnitude without losing model fidelity.
Future Roadmap
Planned technical enhancements, new feature modules, and architectural extensions.
Real-Time Graph Neural Network (GNN)
Incorporate graph relationships between cards, IPs, and merchants to identify coordinated fraud rings.
Automated Drift Detection & Retraining
Build continuous evaluation pipelines with Evidently AI to trigger retrains when data distributions drift.
Streaming Kafka Pipeline Integration
Upgrade event ingestion from REST to Apache Kafka for multi-million event throughput.
An intelligent ergonomic workstation profiler that generates tailored hardware setups based on spatial, physiological, and budget constraints.
Manual expense tracking is tedious and error-prone. SmartExpenseAI automates financial categorization by ingesting receipts via generative multimodal AI.