Inspiration
Online payment fraud costs billions every year, and most victims only find out after the money is gone. We wanted to build an AI agent that evaluates a transaction before it completes and explains its decision, so a human reviewer can trust it instead of facing a black-box score.
What it does
FraudShield AI is a real-time fraud detection API for payment platforms like PayPal. A platform sends it transaction details (amount, time of day, device, location, recent activity), and it returns:
- a risk score from 0 to 1
- a recommended action:
approve,review, orblock - human-readable reasons, such as "Unrecognized device" or "Rapid repeated transactions"
Example request:
{"amount": 2500, "hour": 3, "new_device": true, "foreign_location": true, "txns_last_hour": 5}
Example response:
{"risk_score": 0.94, "action": "block", "reasons": ["High transaction amount", "Unrecognized device", "Unusual location", "Rapid repeated transactions", "Late-night activity"]}
How we built it
- FastAPI and Pydantic for the REST API with validated input and auto-generated Swagger docs
- scikit-learn Random Forest classifier that outputs fraud probability
- A rule-based explanation layer that turns risky features into plain-language reasons
- Three-tier decisioning (approve / review / block) so borderline cases go to a human instead of being declined outright
- joblib to persist and load the trained model; Uvicorn to serve it
Challenges we ran into
- Real fraud data is private, so we trained on synthetic transactions that simulate common fraud patterns (large amounts, new devices, foreign locations, rapid-fire transactions, late-night activity).
- Fraud is rare, so the data is heavily imbalanced. We used balanced class weights so the model doesn't just predict "safe" every time.
- Balancing fraud caught against legitimate customers blocked led us to the three-tier threshold design.
What we learned
How to serve an ML model behind a production-style API, how to handle imbalanced classification, and why explainability matters in financial decisions.
What's next for FraudShield AI
- Train on real anonymized datasets (e.g. the Kaggle credit card fraud dataset)
- Integrate with PayPal's sandbox APIs
- Add a reviewer dashboard
- Add authentication, rate limiting, and model monitoring for drift
Built With
- fastapi
- github
- joblib
- machine-learning
- numpy
- pydantic
- python
- rest-api
- scikit-learn
- swagger
- uvicorn
Log in or sign up for Devpost to join the conversation.