This repository contains a transaction risk assessment system that ingests transaction-level data, computes risk-related features, and returns a risk score and decision through an API. The system includes a backend inference service, a rule-based decision layer, and a lightweight UI for interactive testing.
-
FastAPI Inference API
https://transaction-risk-system-v2.onrender.com/ -
Flask UI (Client Interface)
https://transaction-risk-system-ui.onrender.com/
The goal of this system is to:
- Ingest transaction-level data
- Engineer fraud/risk-relevant features
- Serve ML-based risk decisions via a low-latency API
- Provide a UI for interactive testing
- Maintain production discipline via CI/CD and security checks
This repository is intentionally structured to mirror real-world fintech / risk-engineering systems rather than a notebook-style ML project.
flowchart LR
User[User / Client]
UI[Flask UI]
API[FastAPI Inference API]
DE[Decision Engine]
Model[ML Model]
Data[(Feature Store)]
User --> UI
UI --> API
API --> DE
DE --> Model
DE --> Data
Model --> DE
DE --> API
API --> UI
TRANSACTION-RISK-SYSTEM-V2/
│
├── .github/ # CI/CD workflows (GitHub Actions)
├── data/ # Data lifecycle management
│ ├── raw/ # Raw, untouched data
│ ├── validated/ # Schema-validated data
│ ├── curated/ # Cleaned & model-ready data
│ └── features/ # Engineered feature outputs
│
├── docs/ # System documentation
│ └── decision_framing.md # Risk logic & decision rationale
│
├── src/ # Application source code
│ ├── api/ # FastAPI service (inference layer)
│ ├── decision_engine/ # Core risk & rule-based logic
│ ├── ingestion/ # Data ingestion & validation
│ ├── features/ # Feature engineering pipeline
│ ├── models/ # Model loading & artifacts
│ ├── config/ # Configurations & constants
│ └── ui/ # Flask-based UI client
│
├── requirements.txt # Python dependencies
├── .gitignore
└── README.md
flowchart TD
Raw[Raw Transactions]
Validate[Schema Validation]
Curate[Cleaning & Sorting]
FeatureEng[Feature Engineering]
FeatureStore[(Feature Store)]
Raw --> Validate
Validate --> Curate
Curate --> FeatureEng
FeatureEng --> FeatureStore
- PCA components (V1–V28)
- Transaction amount & log amount
- Velocity features (tx_count_last_600, tx_count_last_3600)
- Rule-derived risk flags
The Decision Engine is responsible for:
- Accepting a feature vector
- Scaling and transforming inputs
- Running ML inference
- Applying rule-based thresholds
- Returning a structured decision
flowchart LR
Input[Feature Vector]
Scale[Scaler]
Infer[ML Inference]
Rules[Risk Rules]
Output[Decision + Risk Score]
Input --> Scale --> Infer --> Rules --> Output
Base URL:
https://transaction-risk-system-v2.onrender.com/
Method: POST
Request Body:
{
"feature_vector": {
"Time": 123456,
"V1": 0.0,
"V2": 0.0,
"...": "...",
"Amount": 149.62,
"tx_count_last_600": 1,
"tx_count_last_3600": 4
}
}Response:
{
"risk_score": 0.73,
"decision": "DECLINE"
}The UI is intentionally kept thin:
- No ML logic
- No feature engineering
- Only acts as a client to the FastAPI service
Live UI:
https://transaction-risk-system-ui.onrender.com/
- Sensible defaults (V1–V28 default to 0)
- Advanced features hidden by default
- Manual override supported for testing
This repository uses GitHub Actions to enforce production discipline.
flowchart LR
Commit[Git Push]
Test[Test & Lint]
Security[Security Scan]
Build[Build Verification]
Deploy[Render Auto Deploy]
Commit --> Test --> Security --> Build --> Deploy
- Multi-version Python testing (3.9–3.11)
- Linting (flake8)
- Unit tests (pytest)
- Security scans (Bandit, Safety)
- Import & build verification
- No secrets hardcoded
- Dependency vulnerability scanning
- Non-blocking security reporting
- Environment parity across local, CI, and production
# Create environment
python -m venv .venv
source .venv/bin/activate # On Windows: .venv\Scripts\activate
# Install dependencies
pip install -r requirements.txt
# Run FastAPI
uvicorn src.api.app:app --reload
# Run UI
cd src/ui
python app.pyThis project prioritizes:
- Separation of concerns - Clear boundaries between data, logic, and presentation layers
- Production realism over toy examples - Mimics actual production system architecture
- Explainability and traceability - Every decision can be audited and explained
- Interview-ready architecture - Demonstrates system design and engineering best practices
- Model versioning and A/B testing framework
- Drift detection & monitoring
- Authentication & rate limiting
- Feature store abstraction (e.g., Feast integration)
- Event-driven ingestion pipeline
- Horizontal scaling with load balancing
- Real-time monitoring dashboards
- Backend: FastAPI, Flask
- ML: scikit-learn, XGBoost
- Data Processing: pandas, NumPy
- Deployment: Render (serverless)
- CI/CD: GitHub Actions
- Security: Bandit, Safety
Prateek
Built as a production-style ML system to demonstrate readiness for Data Scientist / ML Engineer roles at leading technology companies.
"Good models impress. Reliable systems get deployed."
