Skip to content

About

AI fraud detection system with FastAPI, ML pipeline, and Cloudflare deployment

Resources

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

🛡️ AI Fraud Detection System

Python FastAPI License Status

Real-time transaction fraud detection with ML pipeline, REST API, and Cloudflare Workers deployment


✨ Features

  • 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

🛠️ Tech Stack

Python FastAPI Scikit-learn PostgreSQL Docker Cloudflare

🚀 Quick Start

# 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 Deployment

docker-compose up --build

Cloudflare Workers

npm install -g wrangler
wrangler deploy

📡 API Endpoints

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

🏗️ Architecture

Transaction Request
        │
        ▼
┌─────────────────┐
│   FastAPI       │
│   (Cloudflare)  │
└────────┬────────┘
         │
┌────────▼────────┐
│  Feature        │
│  Engineering    │
└────────┬────────┘
         │
┌────────▼────────┐
│  ML Model       │
│  (XGBoost)      │
└────────┬────────┘
         │
┌────────▼────────┐
│  PostgreSQL     │
│  (Storage)      │
└─────────────────┘

🌐 Live Demo

Platform URL
GitHub Pages raphasha27.github.io/python-ai-fraud-detection
Docker Hub hub.docker.com/r/raphasha27/python-ai-fraud-detection
Cloudflare Pages fraud-detection-api-3pg.pages.dev

📊 Model Performance

Metric Score
Accuracy 98.2%
Precision 96.8%
Recall 94.5%
F1 Score 95.6%
AUC-ROC 0.991

👤 Author

raphasha27 — GitHub

About

AI fraud detection system with FastAPI, ML pipeline, and Cloudflare deployment

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Used by

Contributors

Languages