# M-Pesa Fraud Detection ML Platform
## Project Highlights
- Built an end-to-end M-Pesa fraud detection platform using Kafka, PostgreSQL, FastAPI, MLflow, and Docker
- Simulated realistic transaction streams across 58 Kenyan cities
- Engineered 20 fraud features spanning behavioral, temporal, velocity, and amount patterns
- Added model monitoring, prediction logging, and drift detection
- Automated testing and CI validation using GitHub Actions
An end-to-end ML platform for near real-time fraud detection on M-Pesa transactions. This project demonstrates production-style data engineering across streaming ingestion, feature engineering, model training, API serving, drift monitoring, and automated testing, built with a Kenyan fintech context using realistic M-Pesa transaction types, Kenyan names, KES amounts, and location data across 58 Kenyan cities.
---
## Platform Preview
**Streamlit Dashboard**
**MLflow Experiment Tracking**
**FastAPI Interactive Docs**
---
## Business Problem
M-Pesa processes millions of financial transactions daily. Fraud patterns, including velocity attacks, account takeovers, and suspicious high-value transfers, evolve continuously and require automated detection systems that can score transactions in near real time.
This platform detects:
- Unusual spending behaviour relative to a sender's historical baseline
- Rapid transaction bursts within short time windows
- Account takeover signals via new device and new location combinations
- Statistically extreme amounts using z-score analysis
---
## Architecture
The platform is built in 8 layers, each feeding the next:
---
## Tech Stack
| Layer | Technology |
|---|---|
| Streaming | Apache Kafka 7.4.0, confluent-kafka 2.6.1 |
| Database | PostgreSQL 18, SQLAlchemy 2.0.36, psycopg2 2.9.11 |
| Feature Engineering | Python 3.13, Pandas 2.2.3 |
| Machine Learning | scikit-learn 1.5.2, XGBoost 2.1.3, imbalanced-learn 0.12.4 |
| Experiment Tracking | MLflow 2.18.0 |
| API Se …