Skip to content

Latest commit

Β 

History

History
103 lines (74 loc) Β· 2.71 KB

README.md

File metadata and controls

103 lines (74 loc) Β· 2.71 KB

πŸ›‘οΈ Sentinel: Real-Time Fraud Detection System

Python FastAPI ML Docker Status

Sentinel is an end-to-end, machine-learning-powered fraud detection system that analyzes financial transactions within milliseconds.

Built using modern MLOps principles, it unifies data processing, model training, API services, database logging, and monitoring dashboards under a single architecture.


πŸ—οΈ System Architecture

graph LR
    User[Client / Simulator] -->|POST /predict| API[FastAPI Service]
    API -->|1. Preprocessing| Preproc[Feature Engineering]
    Preproc -->|2. Inference| Model[XGBoost Pipeline]
    Model -->|3. Prediction| API
    API -->|4. Logging| DB[(SQLite / Postgres)]
    API -->|Response| User
    User -->|Monitor| Dashboard[Streamlit App]
Loading

πŸš€ Features

  • Advanced Feature Engineering: Time-based and geo-mismatch feature extraction.
  • Imbalance Handling: Uses scale_pos_weight for highly imbalanced datasets.
  • Robust API: Async FastAPI architecture with Pydantic v2 validation.
  • Audit Trail: Every prediction is logged into the database.
  • Dockerized: Entire system can be launched with a single command.

πŸ› οΈ Installation

1. Using Docker (Recommended)

make up
# Stop the system
make down

API: http://localhost:8000/docs Dashboard: http://localhost:8501

2. Manual Installation

# Create a virtual environment
python -m venv .venv
source .venv/bin/activate

# Install dependencies
pip install -r requirements.txt

# Run training
python src/ml_core/train.py

# Start the API
python src/main.py

# Start the dashboard
streamlit run dashboard.py

πŸ§ͺ Testing

Automated tests ensure system reliability.

make test
# or
pytest -v

πŸ“‚ Project Structure

sentinel-fraud-detection-system/
β”œβ”€β”€ src/
β”‚   β”œβ”€β”€ ml_core/       # Model training & artifacts
β”‚   β”œβ”€β”€ routers/       # API endpoints
β”‚   β”œβ”€β”€ services/      # Business logic (Inference & Preprocessing)
β”‚   β”œβ”€β”€ db/            # Database connections
β”‚   └── models/        # SQLAlchemy schemas
β”œβ”€β”€ tests/             # Integration tests
β”œβ”€β”€ dashboard.py       # Streamlit monitoring dashboard
β”œβ”€β”€ Dockerfile         # Container definition
└── Makefile           # Command automation

Developed by Efekan Salman β€” 2025