How bhaavinjain/real-time-financial-fraud-detection-system works
This is a real-time transaction fraud detection product: transactions enter through the Streamlit analyst dashboard or the FastAPI prediction API, are validated and transformed, scored by an XGBoost/autoencoder ensemble, and returned with a fraud verdict and SHAP explanation. The dashboard supports batch review, a quick demo, and model-performance reporting; the API also exposes health and running metrics. The graph follows the documented deployment and prediction flow. Model-training and notebook internals are not sampled, so their details are not expanded.
Main entry points: main.py FastAPI service · app.py Dashboard · schemas.py Input and output schemas · preprocessing.py Feature preparation
Components 15
User interface
- Dashboard
dashboard/app.py - Batch review
dashboard/app.py - Quick demo
dashboard/app.py - Model performance
dashboard/app.py
API serving
- FastAPI service
api/main.py - Input and output schemas
api/schemas.py - Health and metrics
api/main.py
Inference pipeline
- Feature preparation
api/preprocessing.py - XGBoost classifier
models/xgboost_best.pkl - Anomaly scoring
models/autoencoder.keras - Ensemble decision
models/ensemble_config.pkl - SHAP explanation
models/shap_explainer.pkl
Model artifacts
- Inference assets
models
Other components
- Fraud analyst
- Payment processor
Connections 17
- Fraud analyst → Dashboard: uses
README.md - Payment processor → FastAPI service: submits transactions
README.md - Dashboard → FastAPI service: sends HTTPS requests
README.md - Dashboard → Batch review: offers
dashboard/app.py - Dashboard → Quick demo: offers
dashboard/app.py - Dashboard → Model performance: offers
dashboard/app.py - Batch review → FastAPI service: requests scores
dashboard/app.py - Quick demo → FastAPI service: requests score
dashboard/app.py - Dashboard → Health and metrics: reads status
dashboard/app.py - FastAPI service → Input and output schemas: validates and returns
api/main.py - FastAPI service → Feature preparation: engineers and encodes
api/main.py - FastAPI service → XGBoost classifier: predicts probability
api/main.py - FastAPI service → Anomaly scoring: computes reconstruction
api/main.py - FastAPI service → Ensemble decision: calculates verdict
api/main.py - FastAPI service → SHAP explanation: computes SHAP values
api/main.py - FastAPI service → Inference assets: loads at startup
api/main.py - FastAPI service → Health and metrics: serves endpoints
api/main.py