How shyam062006/fraud-shield works
FRAUD SHIELD scores payment transactions and returns a verdict with model-grounded explanations. The main workflow runs from operator input in the browser, through the injected bridge and validated API request, to feature engineering, model inference, and explanation generation; the bridge then renders the result. The README also describes model benchmarking and the model-info endpoint. Source excerpts show the prediction path and API/UI wiring; training details beyond the documented benchmark are not inspected.
Main entry points: main.py FastAPI Service · model_service.py Model Inference and Attribution · bridge.js Runtime Bridge · index.html Fraud UI
Components 13
Transaction UI
- Fraud UI
frontend/index.html - Runtime Bridge
backend/static/bridge.js
API and Contracts
- FastAPI Service
backend/app/main.py - Request and Response Schemas
backend/app/schemas.py - Runtime Settings
backend/app/config.py
Fraud Analysis
- Feature Engineering
backend/app/features.py - Model Inference and Attribution
backend/app/model_service.py - Risk Explanations
backend/app/explain.py
Model Assets and Evaluation
- Random Forest Artifact
ML/model.pkl - Scaler Artifact
ML/scaler.pkl - Benchmark Metrics
backend/app/metrics.json - Training and Benchmark
ML/train_final_model.ipynb
Other components
- Transaction Operator
Connections 16
- Transaction Operator → Fraud UI: enters transaction
README.md - Fraud UI → Runtime Bridge: receives injection
- Runtime Bridge → FastAPI Service: posts prediction
backend/static/bridge.js - FastAPI Service → Request and Response Schemas: validates and responds
backend/app/main.py - FastAPI Service → Feature Engineering: extracts features
backend/app/main.py - FastAPI Service → Model Inference and Attribution: requests inference
backend/app/main.py - FastAPI Service → Risk Explanations: generates reasons
backend/app/main.py - Model Inference and Attribution → Feature Engineering: uses feature names
backend/app/model_service.py - Model Inference and Attribution → Runtime Settings: resolves artifact paths
backend/app/model_service.py - Model Inference and Attribution → Random Forest Artifact: loads model
backend/app/model_service.py - Model Inference and Attribution → Scaler Artifact: loads scaler
backend/app/model_service.py - FastAPI Service → Runtime Settings: reads runtime settings
backend/app/main.py - FastAPI Service → Benchmark Metrics: reads metrics
backend/app/main.py - Runtime Bridge → Fraud UI: renders prediction
backend/static/bridge.js - Training and Benchmark → Random Forest Artifact: produces production model
README.md - Training and Benchmark → Scaler Artifact: produces scaler
README.md