Most fraud detection stacks make you pick a lane.
Rule engines are fast and predictable, but rigid — they miss anything that doesn't match a pattern someone already wrote down. ML models catch the unknown stuff, but they're slow to run at scale and impossible to explain to a compliance team ("the model said 0.87, trust me"). And almost nobody looks at the relationships between transactions — so a fraud ring using ten stolen cards from the same device just looks like ten unrelated flagged purchases.
I built FraudShield to stop treating these as separate problems. It's an open-source, real-time fraud detection platform that runs a rule engine, an ML ensemble, and graph analytics together, on every transaction, in under 10ms.
- 🔗 Live demo: https://fraudshield-blue-seven.vercel.app/
- 🔗 Source: https://github.com/Shweta-Mishra-ai/fraudshield
- 📜 License: MIT
The architecture: three detection layers, one decision
Instead of picking rules or ML or graph analysis, FraudShield runs all three in parallel and combines them into a single weighted decision:
- Rule engine — 9 behavioral fraud rules covering things like transaction velocity, geographic anomalies, and device/IP mismatches. Fast, deterministic, and easy to audit.
- ML ensemble — XGBoost + Isolation Forest working together. XGBoost handles supervised classification on labeled fraud patterns; Isolation Forest catches anomalies that don't look like anything the model has seen before.
- Graph analytics — built on NetworkX, this layer looks for fraud rings: shared devices, shared IPs, and connection patterns across otherwise-unrelated transactions. This is the layer that catches coordinated fraud, not just one-off bad actors.
Every transaction gets scored by all three, and the result is one of three decisions: ALLOW, REVIEW, or BLOCK — along with a risk score and a plain-language reason.
Real-time streaming, not batch scoring
The detection engine runs on Pathway, a Rust-based streaming framework, which is what gets latency down to sub-10ms per transaction while handling 100k+ transactions/second. There's also a polling-based fallback engine for environments where the native streaming mode isn't available (Windows/WSL), so it doesn't fall over outside a Linux box.
Explainability isn't an afterthought
Every flagged transaction ships with SHAP-based explanations, so "why was this blocked" has an actual, inspectable answer instead of a confidence score nobody can act on. For a live example, the demo shows real output like:
Merchant category 'electronics' is elevated risk
Card-not-present on 'electronics' (risk 0.65)
That's the kind of reasoning an analyst — or a compliance auditor — can actually work with.
Security, because it's handling transaction data
- PII is SHA-256 hashed before it ever touches the database
- API key auth via
X-API-Keyheader - Rate limiting (HTTP 429 on abuse)
- SQL injection prevention
- Standard security headers (CSP, X-Frame-Options, X-Content-Type-Options)
Tech stack
| Layer | Tech |
|---|---|
| API | Python 3.10+, FastAPI, Uvicorn |
| Streaming | Pathway (Rust engine) |
| ML | XGBoost, Isolation Forest |
| Graph analytics | NetworkX |
| Storage | PostgreSQL / SQLite |
| Web dashboard | Next.js 14, Tailwind CSS |
| Analyst console | Streamlit |
Calling the API
Integration is one POST request. JSON in, decision out:
import requests
response = requests.post(
"https://fraudshield-api.onrender.com/api/v2/transactions/analyze",
headers={"X-API-Key": "your-api-key"},
json={
"user_id": "USER_001",
"amount": 299.99,
"currency": "USD",
"merchant_id": "SHOP_001",
"merchant_category": "electronics",
"location": "US",
"device_id": "DEVICE_001",
"ip_address": "192.168.1.1",
"channel": "online"
}
)
result = response.json()
print(result["decision"]) # ALLOW / REVIEW / BLOCK
print(result["score"]) # 0.0 - 1.0
print(result["reasons"]) # Why it was flagged
print(result["latency_ms"]) # < 10ms
Other endpoints worth knowing about:
| Method | Endpoint | Purpose |
|---|---|---|
| POST | /api/v2/evaluate |
Real-time transaction evaluation |
| GET | /api/v2/alerts |
Retrieve flagged transactions |
| POST | /api/v2/alerts/{id}/review |
Submit analyst review |
| GET | /api/v2/stats |
System throughput metrics |
| GET | /api/v2/health |
Health check (no auth) |
Repo structure
fraudshield/
├── apps/api/ # FastAPI backend, detection engine, streaming
├── apps/web/ # Next.js 14 web dashboard
├── dashboard/ # Streamlit command center
├── docs/ # Architecture documentation and diagrams
├── requirements.txt # Python dependencies
└── ... # setup & contribution guides
Getting started
Self-hosting is free, forever, under MIT license:
git clone https://github.com/Shweta-Mishra-ai/fraudshield.git
python -m venv venv && source venv/bin/activate
pip install -r requirements.txt
streamlit run app.py # dashboard on localhost:8501
Or skip setup entirely and hit the cloud API — sign up, get a free API key instantly, no credit card, and you can send your first transaction in about 5 minutes. There's also an "Instant Demo Key" option if you just want to poke at it without creating an account.
Currently sitting at 180 passing tests, with the analyst dashboard, review queue, and fraud ring visualization built in — no extra tooling required.
Where this is headed
Right now this is a solo open-source project — rule engine, ML layer, and graph layer are all working together, but there's plenty on the roadmap: more fraud rule coverage, expanded graph ring detection, and (eventually) paid tiers for higher transaction volumes on the cloud API, while the self-hosted version stays free forever.
If you're working on anything in fraud, risk, or trust & safety, I'd genuinely like to hear how you're approaching the rules-vs-ML-vs-graph trade-off — drop a comment or open an issue.
Repo: https://github.com/Shweta-Mishra-ai/fraudshield
Live demo: https://fraudshield-blue-seven.vercel.app/
Built with FastAPI, Pathway, XGBoost, and NetworkX. MIT licensed — self-host it, fork it, break it, tell me what's missing.