Skip to content

RaviTeja799/Predictive_Transaction_Intelligence_For_BFSI

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

84 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸ›‘οΈ TransIntelliFlow - Fraud Detection System

Status Python React FastAPI License

AI-Powered Real-Time Fraud Detection for Banking & Financial Services

Features β€’ Quick Start β€’ Documentation β€’ API β€’ Contributing


πŸ“– Overview

TransIntelliFlow is an enterprise-grade fraud detection system that combines Machine Learning, AI-assisted explainability, and realistic simulations to identify fraudulent transactions in real-time for the Banking, Financial Services, and Insurance (BFSI) sector.


πŸ—οΈ Architecture

πŸ“¦ TransIntelliFlow/
β”‚
β”œβ”€β”€ 🐍 backend/                    # Python Backend (FastAPI)
β”‚   β”œβ”€β”€ src/
β”‚   β”‚   β”œβ”€β”€ preprocessing/         # Data cleaning & feature engineering
β”‚   β”‚   β”œβ”€β”€ modeling/              # ML model training & evaluation
β”‚   β”‚   β”œβ”€β”€ detection/             # Fraud detection engine
β”‚   β”‚   β”œβ”€β”€ api/                   # REST API endpoints
β”‚   β”‚   └── utils/                 # Helper functions
β”‚   β”œβ”€β”€ data/
β”‚   β”‚   β”œβ”€β”€ raw/                   # Original datasets
β”‚   β”‚   └── processed/             # Cleaned datasets
β”‚   β”œβ”€β”€ outputs/
β”‚   β”‚   β”œβ”€β”€ models/                # Trained ML models
β”‚   β”‚   └── eda_reports/           # Analysis reports
β”‚   β”œβ”€β”€ notebooks/                 # Jupyter notebooks
β”‚   β”œβ”€β”€ tests/                     # Unit tests
β”‚   └── requirements.txt
β”‚
β”œβ”€β”€ βš›οΈ frontend/                   # React Frontend
β”‚   β”œβ”€β”€ src/
β”‚   β”‚   β”œβ”€β”€ components/            # React components
β”‚   β”‚   β”œβ”€β”€ services/              # API integration
β”‚   β”‚   └── pages/                 # Application pages
β”‚   β”œβ”€β”€ public/                    # Static assets
β”‚   └── package.json
β”‚
└── πŸ“š docs/                       # Documentation

✨ Features

Backend Features

  • πŸ” Data Preprocessing Pipeline - Automated data cleaning and transformation
  • πŸ“Š Comprehensive EDA - 8+ visualization reports with insights
  • πŸ€– Multiple ML Models - XGBoost, Random Forest with hyperparameter tuning
  • ⚑ Real-time Detection - Sub-second fraud prediction
  • 🎯 Risk Scoring - Multi-factor risk assessment (Low/Medium/High/Critical)
  • 🚨 Smart Alerting - Automated alerts for suspicious transactions
  • πŸ“‘ RESTful API - 6+ endpoints for seamless integration
  • πŸ’Ύ Model Persistence - Save and load trained models

Frontend Features

  • πŸ“ Transaction Form - Easy transaction submission
  • 🎨 Real-time Dashboard - Live fraud detection results
  • πŸ“ˆ Metrics Visualization - Model performance charts
  • πŸ“‹ Transaction History - Searchable transaction log
  • 🎯 Risk Indicators - Visual risk level display
  • πŸ“± Responsive Design - Works on all devices
  • ⚠️ Alert System - Real-time fraud notifications
  • πŸ“§ Email Alert Simulation - Automated security alerts for high-risk transactions with recipient tracking
  • πŸ§ͺ Simulation Lab Overlay - Blend the last 500 simulation transactions into the dashboard without disturbing the curated baseline dataset
  • 🀝 Modeling Workspace AI - Gemini explains model metrics and per-transaction predictions directly inside the app
  • πŸ’¬ Feedback Loop - Mark predictions as correct/incorrect for model improvement
  • πŸŒ™ Dark Mode - Full dark mode support across all screens

πŸ” Demo Workflows

Simulation Lab + Dashboard Overlay

  1. Open the Simulation Lab screen in the frontend and submit a batch (default 100 transactions).
  2. FastAPI processes every transaction with the real model, applies realistic heuristics (9–15% fraud), and stores the last 500 results in an in-memory overlay buffer.
  3. The dashboard can optionally overlay this buffer to showcase live spikes while the baseline 200 curated transactions stay unchanged.
  4. Backend endpoints involved:
  • POST /api/simulation/batch
  • GET /api/simulation/overlay

Gemini-Powered Explainability

  1. Ensure GEMINI_API_KEY is present in the backend .env (see Environment variables).
  2. The Modeling Workspace calls GET /api/modeling/explain for global summaries and POST /api/modeling/predict/explain for transaction-level narratives.
  3. Responses always include fallback text so the UI never breaks if the external API is unavailable.

πŸš€ Quick Start

Prerequisites

  • Python 3.11+
  • Node.js 18+
  • Git

Backend Setup

# Clone repository
git clone https://github.com/RaviTeja799/Infosys-springboard-project.git
cd Infosys-springboard-project

# Navigate to backend
cd backend

# Create virtual environment
python -m venv venv

# Activate virtual environment
# Windows:
venv\Scripts\activate
# Linux/Mac:
source venv/bin/activate

# Install dependencies
pip install -r requirements.txt

# Run API server
uvicorn src.api.main:app --reload

Environment variables

Create a .env file inside backend/ (or export the values in your shell) before starting uvicorn:

USE_MOCK_DATA=true                  # serves cached Indian mock data when MongoDB is empty
GEMINI_API_KEY=your-google-key      # enables AI explanations in Modeling Workspace
GEMINI_MODEL=gemini-1.5-flash       # optional override; defaults to gemini-1.5-flash

Tip: leave USE_MOCK_DATA=true for demos so the React dashboard always receives consistent Indian locations/channels. Toggle it off when connecting to a real MongoDB instance.

Backend will run on: http://localhost:8000
API Documentation: http://localhost:8000/docs

Frontend Setup

# Navigate to frontend (from project root)
cd frontend

# Install dependencies
npm install

# Start development server
npm run dev

Frontend will run on: http://localhost:5173


πŸ”Œ API Endpoints

Authentication

POST /api/auth/register    # Register new user
POST /api/auth/login       # Login user
GET  /api/auth/me          # Get current user

Fraud Detection

POST /api/predict          # Predict single transaction
POST /api/batch-predict    # Predict multiple transactions
GET  /api/transactions     # Get transaction history
GET  /api/metrics          # Get model performance metrics

Example: Predict Fraud

Request:

curl -X POST "http://localhost:8000/api/predict" \
  -H "Content-Type: application/json" \
  -d '{
    "transaction_id": "T1001",
    "customer_id": "C123",
    "amount": 5000,
    "channel": "online",
    "timestamp": "2024-01-15T10:30:00",
    "account_age_days": 365,
    "kyc_verified": true
  }'

Response:

{
  "transaction_id": "T1001",
  "prediction": "Fraud",
  "risk_score": 0.85,
  "risk_level": "High",
  "confidence": 0.95,
  "alerts": [
    "High transaction amount: $5000",
    "Suspicious hour: 22:00"
  ]
}

πŸ“Š Project Modules

Module Timeline Status Description
Module 1 Weeks 1-2 βœ… Complete Data Collection & Preprocessing
Module 2 Weeks 3-4 βœ… Complete Predictive Transaction Modeling
Module 3 Weeks 5-6 βœ… Complete Real-Time Fraud Detection Engine
Module 4 Weeks 7-8 βœ… Complete Deployment & Integration

Module Details

πŸ“₯ Module 1: Data Collection & Preprocessing βœ…

  • Data loading and validation
  • Missing value handling
  • Feature engineering (temporal, amount-based)
  • Data splitting (70/15/15)
  • Exploratory Data Analysis (EDA)
  • Data quality checks

πŸ€– Module 2: Predictive Transaction Modeling βœ…

  • Model training (XGBoost, Random Forest)
  • Hyperparameter tuning
  • Performance evaluation (Accuracy, Precision, Recall, F1, AUC)
  • Model persistence and versioning
  • Feature importance analysis

πŸ” Module 3: Real-Time Fraud Detection Engine βœ…

  • FastAPI-based detection system
  • Real-time transaction analysis
  • Risk scoring engine
  • Alert generation system
  • Email notification simulation
  • Fraud signature matching
  • Behavioral deviation analysis

πŸš€ Module 4: Deployment & Integration βœ…

  • FastAPI REST API deployment
  • React dashboard with TypeScript
  • MongoDB Atlas integration
  • Gemini AI integration
  • API documentation (Swagger/OpenAPI)
  • System health monitoring
  • Production-ready configuration

πŸ› οΈ Technology Stack

Backend

Category Technology
Language Python 3.11+
Framework FastAPI
ML/AI Scikit-learn, XGBoost, Pandas, NumPy
Visualization Matplotlib, Seaborn
Database MongoDB
Authentication JWT (JSON Web Tokens)
Testing Pytest
API Docs Swagger/OpenAPI

Frontend

Category Technology
Framework React 18+ with TypeScript
Build Tool Vite
Styling TailwindCSS
UI Components Shadcn/ui
State Management Zustand / Redux
Data Fetching React Query, Axios
Charts Recharts, Chart.js
Routing React Router v6

πŸ§ͺ Testing

Backend Tests

cd backend

# Run all tests
pytest tests/

# Run with coverage
pytest --cov=src tests/

# Run specific test file
pytest tests/test_preprocessing.py

Frontend Tests

cd frontend

# Run tests
npm test

# Run with coverage
npm run test:coverage

πŸ“š Documentation

Document Description
Backend README Backend setup and API details
Frontend README Frontend setup and components
Project Structure Detailed project organization
Quick Start Guide Get started in 5 minutes
API Documentation Interactive API docs (when running)

🀝 Contributing

We welcome contributions! Here's how you can help:

  1. Fork the repository
  2. Create a feature branch
    git checkout -b feature/AmazingFeature
  3. Commit your changes
    git commit -m 'Add some AmazingFeature'
  4. Push to the branch
    git push origin feature/AmazingFeature
  5. Open a Pull Request

Development Guidelines

  • Follow PEP 8 for Python code
  • Use ESLint for JavaScript/TypeScript
  • Write tests for new features
  • Update documentation
  • Keep commits atomic and descriptive

πŸ“ License

This project is licensed under the MIT License - see the LICENSE file for details.

MIT License

Copyright (c) 2025 TransIntelliFlow

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

This project is part of the Infosys Virtual Internship - BFSI Track.


πŸ‘₯ Team

Role Responsibilities
Backend Team Data preprocessing, ML modeling, API development
Frontend Team React dashboard, UI/UX, API integration
ML Team Model training, evaluation, optimization

πŸ™ Acknowledgments

  • Infosys Springboard - For the virtual internship opportunity
  • BFSI Sector - For real-world problem inspiration
  • Open Source Community - For amazing tools and libraries