Skip to content

Nithin00614/Transaction-Risk-Scoring-System

Repository files navigation

Transaction Risk ML – Real-Time Risk Scoring System

CI Pipeline

Python API Latency Throughput Docker Deploy License

📌 Overview

This project implements a real-time transaction risk scoring system using machine learning.

It predicts the fraud risk probability of a transaction and maps it into actionable decisions:

  • ALLOW → Low risk
  • CHALLENGE → Medium risk
  • BLOCK → High risk

The system follows a production-style ML workflow with clearly separated training and inference pipelines.


Key Features

  • End-to-end ML pipeline (training → inference)
  • Real-time inference using FastAPI
  • CI/CD integration with automated testing
  • Dockerized deployment
  • Structured logging (captured via cloud platform)
  • Scenario-based validation for risk decisions

Model Summary

  • Model: Logistic Regression
  • Preprocessing: StandardScaler
  • Training Data: Synthetic dataset with realistic fraud patterns
  • ROC-AUC: ~0.93

The model outputs a risk probability, which is converted into business decisions using thresholding.


Project Structure

This project follows modular MLOps-inspired structure seprating training, inferenece, and deployment components.

Transaction-Risk-Scoring-System/
├── data/
├── training/
├── inference/
├── models/
├── utils/
├── tests/
├── .github/
│   └── workflows/
|
├── requirements.txt
├── Dockerfile
├── system_design.md
└── README.md

Running the Project

  1. Install dependencies

pip install -r requirements.txt

  1. Train model

python training/train.py

  1. Run inference API

uvicorn inference.app:app --reload

API:

http://127.0.0.1:8000/docs


🌐 Live API

The model is deployed and accessible via a public API.


Example Request

{ "amount": 2500, "account_age_days": 180, "past_txn_count_24h": 5, "hour_of_day": 22, "merchant_risk_score": 0.5 }


Example Response

{ "risk_score": 0.47, "decision": "CHALLENGE" }


⚡ Performance & Load Testing

The system was evaluated under simulated load to validate real-time performance.

  • Tool Used: Locust
  • Throughput: ~160 requests/second
  • Latency: <150 ms (average)
  • Failure Rate: 0% under sustained load

These results demonstrate the system’s ability to handle high-throughput, low-latency inference workloads.


Deployment

docker build -t /transaction-risk-ml . docker run -p 10000:10000 /transaction-risk-ml

The API is deployed on Render with logs streamed via stdout and monitored through the platform dashboard.


Dataset

The dataset used for training is synthetic and not included in this repository.

It simulates real-world fraud scenarios using:

  • Transaction behavior
  • Account characteristics
  • Merchant risk signals

Model Performance

  • Model: Logistic Regression
  • ROC-AUC Score: ~0.93
  • Pipeline: StandardScaler + Logistic Regression

Documentation

For detailed architecture, design decisions, and trade-offs:

➡️ Detailed System Design
Open


About

Production-grade ML system for real-time transaction risk scoring with FastAPI, CI/CD, Docker deployment, and load-tested performance (160 RPS, <150ms latency, 0% failure).

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors