A production-style machine learning system that detects fraudulent transactions in real-time using Kafka streaming, FastAPI inference service, MLflow experiment tracking, and Prometheus + Grafana monitoring.
This project demonstrates end-to-end ML system design used in companies like Stripe, Uber, and PayPal.
Fraud detection systems must process thousands of transactions per second and instantly detect suspicious activity.
This project simulates a real-world fraud detection pipeline where:
- Transactions are generated in real time
- Data is streamed via Kafka
- A trained ML model predicts fraud probability
- Predictions are served via FastAPI
- Metrics are monitored using Prometheus & Grafana
Transaction Producer
│
▼
Kafka Topic
│
▼
Kafka Consumer
│
▼
Feature Processing
│
▼
FastAPI ML Model
│
▼
Fraud Prediction
│
▼
Monitoring & Tracking
├── MLflow
├── Prometheus
└── Grafana
- Python
- Scikit-learn
- Pandas
- Apache Kafka
- Kafka Producer
- Kafka Consumer
- FastAPI
- Uvicorn
- MLflow
- Docker
- Docker Compose
- Prometheus
- Grafana
fraud-ml-platform-v2
│
├── api
│ └── app.py
│
├── training
│ └── train.py
│
├── streaming
│ ├── producer.py
│ └── consumer.py
│
├── monitoring
│ └── prometheus.yml
│
├── model
│ └── model.pkl
│
├── docker-compose.yml
└── README.md
git clone https://github.com/yourusername/fraud-ml-platform.git
cd fraud-ml-platform
python training/train.py
This logs the experiment to MLflow.
docker compose up -d
This launches:
- Kafka
- Zookeeper
- FastAPI
- Producer
- Consumer
- MLflow
- Prometheus
- Grafana
| Service | URL |
|---|---|
| FastAPI | http://localhost:8000 |
| Swagger API Docs | http://localhost:8000/docs |
| MLflow | http://localhost:5000 |
| Prometheus | http://localhost:9090 |
| Grafana | http://localhost:3000 |
Grafana login:
username: admin
password: admin
curl -X POST http://localhost:8000/predict \
-H "Content-Type: application/json" \
-d '{"amount":1000,"device_type":1,"location":2,"merchant":3}'
Example response:
{
"prediction": 0,
"fraud_probability": 0.03
}
Metrics are exposed via:
http://localhost:8000/metrics
Prometheus scrapes metrics and Grafana visualizes:
- Prediction request count
- API latency
- System health
The model uses:
- Transaction amount
- Device type
- Location risk
- Merchant category
Model used:
RandomForestClassifier
✔ Real-time streaming with Kafka ✔ Low-latency ML inference with FastAPI ✔ Experiment tracking with MLflow ✔ Monitoring with Prometheus & Grafana ✔ Containerized microservices using Docker
- Feature Store (Feast)
- Model Drift Detection
- Kubernetes deployment
- CI/CD pipeline
- AWS cloud deployment
Vimal Kumar
LinkedIn: https://www.linkedin.com/in/vimal-k-952745203/
GitHub: https://github.com/vim12345