- Real-time fraud prediction with <100ms latency
- Gradient Boosting model with 98%+ accuracy
- Automated feature engineering pipeline
- RESTful API with OpenAPI documentation
- PostgreSQL for transaction storage
- Docker containerization
- Cloudflare Workers edge deployment
- Comprehensive test suite

# Clone repository
git clone https://github.com/Raphasha27/python-ai-fraud-detection.git
cd python-ai-fraud-detection
# Create virtual environment
python -m venv venv
source venv/bin/activate # Linux/Mac
# venv\Scripts\activate # Windows
# Install dependencies
pip install -e ".[dev]"
# Setup database
docker-compose up -d postgres
# Train model
python scripts/train_model.py
# Run API
uvicorn src.main:app --reload --port 8000
docker-compose up --build
npm install -g wrangler
wrangler deploy
| Method |
Endpoint |
Description |
POST |
/predict |
Predict fraud for transaction |
GET |
/health |
Health check |
GET |
/metrics |
Model metrics |
GET |
/transactions |
List transactions |
GET |
/transactions/{id} |
Get transaction details |
Transaction Request
│
▼
┌─────────────────┐
│ FastAPI │
│ (Cloudflare) │
└────────┬────────┘
│
┌────────▼────────┐
│ Feature │
│ Engineering │
└────────┬────────┘
│
┌────────▼────────┐
│ ML Model │
│ (XGBoost) │
└────────┬────────┘
│
┌────────▼────────┐
│ PostgreSQL │
│ (Storage) │
└─────────────────┘
| Metric |
Score |
| Accuracy |
98.2% |
| Precision |
96.8% |
| Recall |
94.5% |
| F1 Score |
95.6% |
| AUC-ROC |
0.991 |
raphasha27 — GitHub