Skip to content

sangsaist/SentinelBank

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

6 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸ›‘οΈ SentinelBank

Real-Time Bank Transaction Simulator & Fraud Detection Engine

License: MIT Python 3.11+ FastAPI React 18 SQLite WebSockets PRs Welcome

Features β€’ Quick Start β€’ Architecture β€’ Contributing


πŸ“– Table of Contents


🌟 Overview

SentinelBank is a real-time bank transaction simulator featuring a live rule-based fraud detection engine. Engineered for instantaneous risk scoring and monitoring, the system evaluates and classifies live transactions into Safe (green), Suspicious (orange), or Fraud (red) categories, updating connected clients instantly over WebSockets.

🎯 Mission

Provide a dynamic, interactive demonstration of real-time fraud analysis, moving beyond static spreadsheets to visualize how complex patterns like circular transactions and chain layering can be detected and mitigated instantly.

πŸ›οΈ Deployment Model

  • Desktop Dashboard (/): A monitoring center for tracking live events, fraud alerts, and engine telemetry.
  • Mobile Bank App (/mobile): A client interface simulating user transfers and real-time push notifications.
  • Background Engine: A self-driving simulation core delivering autonomous transaction volume.

πŸ’‘ The Problem

Traditional fraud monitoring often relies on delayed, batch-processed transaction analysis, leading to critical visibility gaps:

❌ Current State

  • βœ— Batch processed anti-fraud checks
  • βœ— Delayed response to ongoing attacks
  • βœ— Static, non-visual dashboards
  • βœ— Difficult to simulate attack vectors
  • βœ— High latency between event and alert

βœ… With SentinelBank

  • βœ“ Millisecond-latency transaction scoring
  • βœ“ Instantaneous WebSocket data broadcast
  • βœ“ Visual graph-based layout of fraud rules
  • βœ“ One-click attack vector injection
  • βœ“ Unified view across all network nodes

πŸš€ Our Solution

Real-Time Event Architecture

graph LR
    A[Mobile Client] -->|POST Transaction| B[FastAPI Engine]
    B --> C{Fraud Rules Engine}
    C -->|NetworkX Path Check| D[Graph Analysis]
    C --> E[SQLite Database]
    E --> F[WebSocket Broadcaster]
    F -->|Live Feed| G[Desktop Dashboard]
    F -->|Instant Notification| H[Mobile Client]

    style A fill:#667eea
    style B fill:#764ba2
    style C fill:#f093fb
    style D fill:#4facfe
    style E fill:#00f2fe
    style F fill:#43e97b
    style G fill:#38f9d7
    style H fill:#4facfe
Loading

Core Philosophy

Every transaction is an active event.
The rule engine evaluates immediately.
The dashboard visualizes instantaneously.

By maintaining robust real-time synchronization, the platform ensures that system operators and account holders share a unified, immediate truth state.


✨ Features

πŸ”„ Real-time Sync πŸ›‘οΈ Fraud Engine πŸ“Š Live Dashboard πŸ“± Mobile Client
WebSocket Data NetworkX Graph Transaction Feed Seeded Accounts
Live Reconnection Value Thresholds System Analytics Instant Alerts
Sub-second Update Multi-rule Scoring Alert Feed Block Visiblity

πŸ•΅οΈ For Monitoring Operators (Desktop)

  • πŸ“ˆ View live, streaming transaction feeds in real-time.
  • 🚨 Receive immediate, color-coded Fraud Alerts.
  • 🎯 Inject demo fraud scenarios (e.g., Circular, Layering, Burst) on demand.
  • βš™οΈ Control the background transaction generator (Start/Pause/Stop).

πŸ’³ For Account Holders (Mobile)

  • πŸ’Έ Quickly select seeded demo accounts and execute transfers.
  • πŸ’° Instantly receive incoming-payment notification banners.
  • πŸ›‘ Experience instant transaction blocking upon triggering a fraud rule.

πŸ—οΈ System Architecture

High-Level Architecture

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                    Client Interfaces (React)                 β”‚
β”‚    Desktop Dashboard (Monitor)  β€’  Mobile App (Accounts)     β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β–²β”€β”€β”€β”€β”€β”€β”€β”€β”˜
             HTTP REST   β”‚                           β”‚ WebSockets
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                   Application Layer (FastAPI)                β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”‚
β”‚  β”‚    API     β”‚ Fraud Core  β”‚ Auto Engine β”‚  WS Manager  β”‚  β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                         β”‚ SQLAlchemy ORM
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                  Database Layer (SQLite)                     β”‚
β”‚               Accounts β€’ Transactions β€’ Alerts               β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Event Data Flow (Sequence)

sequenceDiagram
    participant U as Mobile User
    participant A as FastAPI API
    participant E as Fraud Engine
    participant D as SQLite DB
    participant W as WebSocket
    participant M as Dashboard Monitor

    U->>A: Submit Transaction
    A->>E: Evaluate Rules (Graph, Amounts)
    E-->>A: Return Risk Score & Color
    A->>D: Store Transaction & Alert (if any)
    A->>W: Broadcast New State
    W->>M: Instant Dashboard Refresh
    W->>U: Show Success/Blocked
Loading

πŸ› οΈ Technology Stack

Backend

Python FastAPI SQLite SQLAlchemy NetworkX

Frontend

React Vite TailwindCSS Zustand

Component Technology Purpose
Core API Python + FastAPI High-performance asynchronous API & WebSocket server
Storage SQLite + SQLAlchemy Persistence for accounts and transactions
Logic NetworkX Graph theory module for calculating circular transaction paths
UI Engine React + Vite Real-time interactive user interfaces
Styling Tailwind CSS Utility-driven UI rendering
State Zustand Managing live transaction streams frontend-side

πŸš€ Quick Start

Prerequisites

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

Installation in 4 Steps

Step 1. Clone the repository

git clone https://github.com/sangsaist/SentinelBank.git
cd SentinelBank
git checkout dev

Step 2. Start the Backend

cd backend
pip install -r requirements.txt
uvicorn main:app --host 0.0.0.0 --port 8000 --reload

Step 3. Configure Frontend Environment Create .env inside the frontend directory using your Wi-Fi LAN IP address instead of localhost (vital for mobile device connectivity):

# In frontend/.env
VITE_API_URL=http://YOUR_LAN_IP:8000
VITE_WS_URL=ws://YOUR_LAN_IP:8000/ws

Step 4. Start the Frontend

cd frontend
npm install
npm run dev

Access Ports

  • Desktop System Dashboard: http://localhost:5173
  • Mobile Simulator App: http://YOUR_LAN_IP:5173/mobile (Access on your phone)

🎭 Demo Script

  1. Dashboard: Open http://localhost:5173 on a desktop.
  2. Mobile Clients: Have team members open http://YOUR_LAN_IP:5173/mobile on their smartphones.
  3. Simulate Background Noise: Click the Start (▢️) button on the dashboard to enable the autonomous transaction engine.
  4. Trigger Fraud: On a mobile client, log into Account A and transfer β‚Ή95,000 to Account B.
    • Watch the desktop dashboard instantly flash a RED Alert (HIGH_VALUE_TRANSFER).
    • The mobile client immediately receives a Blocked status.
  5. Trigger Safe Txn: Send β‚Ή500 from A to B.
    • Dashboard logs a GREEN (Safe) transaction.
    • User B's phone displays a real-time πŸ’° Money Received banner.
  6. Inject Attacks: Use the dashboard's Fraud Queue Builder to simulate Layering, Smurfing, or Circular bypass attempts.

πŸ“š API Documentation

REST Endpoints

Method Endpoint Description
GET /transactions Fetch latest historical transactions.
GET /fraud-alerts Fetch queued history of fraud detections.
POST /transaction Process a new transfer and run anti-fraud heuristics.
POST /engine/start Ignite continuous background data simulator.
POST /inject/{id} Inject specific attack vectors (Rapid Burst, Circular, etc).
πŸ“– View Transaction JSON Structure

Submit Transaction:

curl -X POST http://localhost:8000/transaction \
  -H "Content-Type: application/json" \
  -d '{
    "sender_id": "A",
    "receiver_id": "B",
    "amount": 50000
  }'

WebSocket Live Broadcast Response:

{
  "type": "transaction",
  "data": {
    "transaction_id": "f5a7d23a",
    "sender_id": "A",
    "receiver_id": "B",
    "amount": 50000,
    "timestamp": "2026-03-14T10:00:00.000000+00:00",
    "is_fraud": 0,
    "risk_score": 0.45,
    "color": "orange",
    "fraud_reason": "UNUSUAL_AMOUNT"
  }
}

πŸ—ΊοΈ Roadmap

  • WebSockets for sub-second system observability
  • NetworkX based multi-node loop mapping
  • Injection tooling for mock-attack demos
  • Migrate SQLite logic natively to PostgreSQL for deep-scale benchmarking
  • Incorporate Machine Learning heuristic models alongside hardcoded rules
  • Integrate React-Native framework structure for actual App Store simulation

πŸ“ Project Structure

SentinelBank/
β”œβ”€β”€ backend/
β”‚   β”œβ”€β”€ app/
β”‚   β”‚   β”œβ”€β”€ api/            # REST endpoint logic 
β”‚   β”‚   β”œβ”€β”€ core/           # Fraud detection engine, scenario injector
β”‚   β”‚   β”œβ”€β”€ db/             # Schema models & data seeders
β”‚   β”‚   β”œβ”€β”€ schemas/        # Request/Response data contracts
β”‚   β”‚   └── websocket/      # Live channel distributors
β”‚   β”œβ”€β”€ main.py             # Server boot configuration
β”‚   └── requirements.txt
β”œβ”€β”€ frontend/
β”‚   β”œβ”€β”€ src/
β”‚   β”‚   β”œβ”€β”€ api/            # Axial API clients
β”‚   β”‚   β”œβ”€β”€ components/     # Visual elements (StatsBar, FraudAlertFeed, etc.)
β”‚   β”‚   β”œβ”€β”€ hooks/          # Real-time WebSocket hook definitions
β”‚   β”‚   β”œβ”€β”€ pages/          # Layout routing endpoints (/ and /mobile)
β”‚   β”‚   └── store/          # Zustand memory cache parameters
β”‚   └── package.json
└── README.md

🀝 Contributing

Contributions are heavily encouraged for the advancement of real-time monitoring strategies!

  1. Fork the repository.
  2. Create a feature branch: git checkout -b feature/enhanced-engine
  3. Commit your progress: git commit -m 'feat: Add parallel scanning queue'
  4. Push into the branch: git push origin feature/enhanced-engine
  5. Open a Pull Request against dev.

πŸ“„ License

This repository is distributed under the MIT License. Check the LICENSE file for additional terms.


Built for Precision

Visualizing complex cyber-financial telemetry before it settles.

⬆ Back to Top

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors