https://github.com/celpha2svx/sentinel-fraud-detection
Cloud-Native Fraud Detection systems(SentinelV3)
https://github.com/celpha2svx/sentinel-fraud-detection
Last synced: 9 days ago
JSON representation
Cloud-Native Fraud Detection systems(SentinelV3)
- Host: GitHub
- URL: https://github.com/celpha2svx/sentinel-fraud-detection
- Owner: celpha2svx
- Created: 2025-12-30T11:43:59.000Z (6 months ago)
- Default Branch: master
- Last Pushed: 2026-06-05T22:53:28.000Z (about 1 month ago)
- Last Synced: 2026-06-06T00:19:48.568Z (about 1 month ago)
- Language: Jupyter Notebook
- Homepage: https://alpha-7g3-sentinel-fraud-detection.hf.space/docs
- Size: 14.9 MB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# π‘οΈ SENTINEL: NIGERIAN FRAUD DETECTION SYSTEM
*AI-Powered Real-Time Fraud Prevention for Nigerian E-Commerce & Fintech*






---
## π Table of Contents
- [The Sentinel Story](#-the-sentinel-story)
- [Overview](#-overview)
- [Model Performance](#-model-performance)
- [Features](#-features)
- [Technology Stack](#-technology-stack)
- [Project Structure](#-project-structure)
- [Getting Started](#-getting-started)
- [Use Cases](#-use-cases)
---
## π The Sentinel Story
In the Nigerian fintech landscape, fraud isn't just a "data problem"βitβs a sophisticated, evolving challenge that targets specific local behaviors. Traditional, generic fraud models often fail here because they don't understand the nuance of a **USSD transfer at 2:00 AM**, the surge of activity during **Salary Week**, or the high-velocity nature of **Opay/Moniepoint** transactions.
**Sentinel** was built to bridge this gap. It doesn't just look at numbers; it looks at patterns. By combining "Surgical" feature engineering (like balance depletion ratios) with a high-performance ensemble of AI models, Sentinel protects both the bank's bottom line and the customer's peace of mind.
> "We built Sentinel to ensure that a legitimate customer in Lagos can spend their money without friction, while a fraudster in a dark room is blocked before the 'Send' button is even cold."
---
## π Overview
Sentinel is a production-grade Fraud Detection API that processes transactions in real-time. It uses a **Voting Ensemble (Random Forest + XGBoost + LightGBM)** to predict the probability of fraud with surgical precision.
### Why Sentinel is different:
* **Locally Contextual:** Engineered specifically for Nigerian banking triggers (USSD, BVN-linkage, Location-based spending).
* **Explainable AI:** Every "BLOCK" decision comes with a human-readable reason and a SHAP-based technical breakdown.
* **Business First:** Includes a built-in ROI calculator that translates model accuracy into **Naira Saved**.
---
## π Model Performance
We don't just chase high accuracy; we chase **Precision**. In fraud detection, a "False Positive" means a frustrated customer who can't pay for their dinner. Sentinel is tuned to avoid that.
| Metric | Result | Meaning |
| :--- | :--- | :--- |
| **AUC-ROC** | **96.7%** | Excellent ability to distinguish between fraud and legit. |
| **Precision** | **99.8%** | Only 4 "False Alarms" out of 12,000+ transactions. |
| **Recall** | **87.9%** | We catch nearly 9 out of every 10 fraud attempts. |
| **False Positive Rate** | **0.03%** | Virtually zero friction for legitimate customers. |
**Net Business Impact (Test Set):**
* **Total Fraud Prevented:** β¦36,165,467.60
* **Customer Friction Cost:** -β¦10,000.00
* **Net Profit:** **β¦36,155,467.60**
---
## β¨ Features
* **β‘ Real-Time Scoring:** Sub-100ms inference using FastAPI and optimized model artifacts.
* **π§ Surgical Engineering:** 26+ features including "Midnight High-Value Shock" and "Balance Depletion Ratio."
* **π Redis-Powered Idempotency:** Prevents duplicate processing of transactions during network retries.
* **π© Automated Webhooks:** Sends instant POST alerts to your internal security systems for "High Risk" flags.
* **βοΈ AI Executive Summaries:** Integrates **Google Gemini 2.0 Flash** to write professional daily fraud reports for management.
* **π Explainability (SHAP):** Transparent AI that tells you *why* it flagged a transaction (e.g., "Amount is 30x higher than typical for Abuja").
---
## π οΈ Technology Stack
* **Core:** Python 3.10+, FastAPI
* **ML/AI:** Scikit-Learn, XGBoost, LightGBM, SHAP, SMOTE (Imbalanced-learn)
* **Data:** Pandas, NumPy, Parquet
* **DevOps/Infra:** Redis (Caching), Uvicorn, Dotenv, Procfile (Heroku/Render ready)
* **Intelligence:** Google Gemini 2.0 (Generative Reports)
---
## π Project Structure
```text
sentinel-fraud-detection/
βββ data/
β βββ nigerian_fraud_sent # Processed features (Parquet)
β βββ nigerian_transactions # Raw transaction data
βββ models/
β βββ model_infos.json # Metadata & Version tracking
β βββ sentinel_ensemble # Trained ensemble model artifact
β βββ sentinel_v2_Encoder # Saved LabelEncoders
βββ notebooks/
β βββ Experiments/
β βββ 01_eda_and_features.ipynb # Behavioral Analysis
β βββ 02_model_training.ipynb # Model calibration
βββ src/
β βββ generator.py # Synthetic data generation logic
β βββ logger.py # Custom logging utility
β βββ predictor.py # Inference wrapper logic
βββ main.py # FastAPI production server
βββ core_function.py # Decision logic & SHAP generators
βββ .env # API keys & Configuration
βββ Features.md # Detailed feature documentation
βββ Procfile # Deployment configuration
βββ README.md # Main documentation
βββ requirements.txt # Python dependencies
βββ sentinel_audit.log # API transaction logs
βββ test_sentinel.py # API integration test script
---
```
## π Getting Started
### Prerequisites
* **Python 3.10+**: Core programming environment.
* **Redis Server**: Required for real-time idempotency and transaction caching (defaults to in-memory if Redis is unavailable).
* **Gemini API Key**: Required for generating the AI Fraud Summary reports.
### Installation
1. **Clone the repository:**
```bash
git clone https://github.com/celpha2svx/sentinel-fraud-detection.git
cd sentinel-fraud-detection
2. Set up the virtual environment:python -m venv venv
```bash
# Windows
venv\Scripts\activate
# Mac/Linux
source venv/bin/activate
```
3. Install dependencies:
```
pip install -r requirements.txt
```
4. Configure Environment Variables:
Create a .env file in the root directory:
```
GEMINI_API_KEY=your_key_here
REDIS_HOST=localhost
REDIS_PORT=6379
```
## Usage:
1. Start the Sentinel Service:
```
uvicorn api.main:app --reload
```
2. Access the Interactive Docs:
Open http://127.0.0.1:8000/docs in your browser to test endpoints via Swagger UI.
### API Testing
βRun the automated test script to simulate a high-risk transaction and verify the SHAP explanation engine:
```
python test_sentinel.py
```
# Use Cases
* Fintech Wallets: Block "Midnight Sweeper" attacks where compromised accounts are drained via USSD while the owner sleeps.
* E-Commerce Checkouts: Flag high-value orders that deviate significantly from a user's 30-day spending baseline.
* Agency Banking: Monitor POS terminals for unusual transaction velocity or large withdrawals in high-risk geographical zones. License
#### This project is licensed under the MIT License - see the LICENSE file for details.
βSentinel: Protecting the pulse of Nigerian Digital Finance.