Skip to content

deveshreddyp/paysheild

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

21 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

PayShield Logo

PayShield ๐Ÿ›ก๏ธ

AI-Powered Fraud Intelligence vs. Client-Side API Tampering

Hackathon Stack Status Live Dashboard Demo Video


๐Ÿš€ Live App: https://payshield-dashboard.onrender.com/
๐ŸŽฅ Demo Video: Watch the attack simulation on Google Drive

๐Ÿšจ The $48 Billion Blind Spot

Modern web applications trust the browser by default. When a user clicks "Pay โ‚น25", the server assumes the incoming API request is genuine.

The reality? Attackers use proxy tools, developer consoles, and browser extensions (like Requestly) to intercept and silently modify API requests mid-flightโ€”changing the amount, the currency, or the destination account before it even reaches the server.

Current Web Application Firewalls (WAFs) and traditional fraud models do not catch this. They scan for malicious code or score data after it arrives, unaware it was tampered with in transit. This is the number one attack vector causing an estimated $48B in digital payment fraud annually.


๐Ÿ’ก The Solution: PayShield (Our Novelty)

PayShield is an end-to-end, microservice-driven fraud intelligence system designed to detect and block API tampering in milliseconds, backed by an AI scoring engine.

Unlike most security projects that use static datasets to "detect fraud", PayShield actively defends against live, simulated attacks in real-time.

๐Ÿ† Why PayShield is Unique

  1. Live Attack Simulation: We prove our security works by attacking our own API during the demo using Requestly (a browser interception extension), demonstrating how invisible tampering is caught live.
  2. The "Replay Engine": A powerful dashboard feature that visually reconstructs the entire lifecycle of a transaction (Browser โ†’ Gateway โ†’ ML Engine โ†’ Decision), explaining exactly why a payment was blocked.
  3. Middleware-Level Interception: We catch tampered requests (e.g., injected headers, modified signatures) at the API edge before they ever reach business logic servers.

๐Ÿ—๏ธ Architecture & Tech Stack

A fully containerized, 4-tier microservice architecture that communicates via REST and WebSockets.

Origin Service Technology Purpose
Client ๐ŸŒ React Dashboard Next.js, Tailwind, WebSockets Real-time threat visualization & Replay Engine
Edge ๐Ÿ›ก๏ธ API Gateway Node.js, Express JWT Auth, Rate Limiting, Idempotency, Tamper Detection Middleware
Brain ๐Ÿง  Fraud AI Python, FastAPI, XGBoost ML scoring on device/geo features; returns risk (0.0 - 1.0) in <50ms
Data ๐Ÿ—„๏ธ In-Memory Stack Redis (Pub/Sub & Cache) Instant event broadcasting & idempotency key storage

๐Ÿš€ How It Works (The Flow)

  1. The browser initiates a payment request.
  2. An attacker (simulated via Requestly) intercepts the request and injects a tampering payload or header.
  3. The PayShield Gateway catches the anomaly in < 2ms, flagging req.tampered = true.
  4. The transaction routes to the Fraud Engine for historical scoring (even if blocked, we want the ML score).
  5. The Gateway immediately drops the transaction (402 FRAUD_FLAGGED).
  6. Redis Pub/Sub pushes the block event to the Next.js Dashboard, instantly showing a red alert and logging the lifecycle in the Replay Engine.

๐ŸŽฎ Running PayShield Locally

We built this to be frictionless for judges to review. The entire system is orchestrated with Docker Compose.

Prerequisites

  • Docker & Docker Compose installed.

Quick Start

# Clone the repository
git clone https://github.com/your-username/payshield.git
cd payshield

# Launch the entire microservice stack
docker-compose up -d --build

Accessing the Services

  • Live Dashboard: http://localhost:4000
  • API Gateway: http://localhost:3000
  • Fraud Engine (Swagger Docs): http://localhost:8000/docs

๐Ÿ“ Project File Structure

payshield/
โ”‚
โ”œโ”€โ”€ ๐Ÿ“‚ dashboard/                    # Next.js Frontend Dashboard (React + WebSocket)
โ”‚   โ”œโ”€โ”€ app/
โ”‚   โ”‚   โ”œโ”€โ”€ components/              # React UI Components
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ AIModelStatus.tsx     # AI model performance display
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ HeatmapClient.tsx     # Geographic heatmap visualization
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ LatencyChart.tsx      # Real-time latency metrics
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ ReplayEngine.tsx      # Transaction lifecycle analyzer
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ RequestlyDemoButton.tsx # Requestly attack simulator
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ RiskPipeline.tsx      # Risk scoring pipeline viz
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ SeedDataButton.tsx    # Demo data seeder
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ StatsPanel.tsx        # Key metrics panel
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ TamperAlert.tsx       # Tampering alerts
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ TrackingStatus.tsx    # Request tracking status
โ”‚   โ”‚   โ”‚   โ””โ”€โ”€ Waterfall.tsx         # Request waterfall diagram
โ”‚   โ”‚   โ”œโ”€โ”€ hooks/                   # Custom React Hooks
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ useLatencyStats.ts    # Latency statistics hook
โ”‚   โ”‚   โ”‚   โ””โ”€โ”€ useWebSocket.ts       # WebSocket connection hook
โ”‚   โ”‚   โ”œโ”€โ”€ types/                   # TypeScript Type Definitions
โ”‚   โ”‚   โ”‚   โ””โ”€โ”€ transaction.ts        # Transaction type schemas
โ”‚   โ”‚   โ”œโ”€โ”€ layout.tsx               # Root layout component
โ”‚   โ”‚   โ”œโ”€โ”€ page.tsx                 # Main dashboard page
โ”‚   โ”‚   โ””โ”€โ”€ globals.css              # Global styles
โ”‚   โ”œโ”€โ”€ public/                      # Static assets
โ”‚   โ”œโ”€โ”€ package.json
โ”‚   โ”œโ”€โ”€ tsconfig.json
โ”‚   โ”œโ”€โ”€ tailwind.config.ts
โ”‚   โ”œโ”€โ”€ postcss.config.js
โ”‚   โ”œโ”€โ”€ Dockerfile
โ”‚   โ””โ”€โ”€ next.config.mjs
โ”‚
โ”œโ”€โ”€ ๐Ÿ“‚ gateway/                      # Node.js Express API Gateway (Edge Layer)
โ”‚   โ”œโ”€โ”€ src/
โ”‚   โ”‚   โ”œโ”€โ”€ middleware/              # Express middleware stack
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ auth.js              # JWT authentication
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ errorHandler.js      # Centralized error handling
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ idempotency.js       # Idempotency key management
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ notFound.js          # 404 handler
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ rateLimit.js         # Rate limiting
โ”‚   โ”‚   โ”‚   โ””โ”€โ”€ security.js          # Security headers & XSS protection
โ”‚   โ”‚   โ”œโ”€โ”€ routes/                  # API endpoint routes
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ auth.js              # Authentication routes
โ”‚   โ”‚   โ”‚   โ””โ”€โ”€ payment.js           # Payment processing routes
โ”‚   โ”‚   โ”œโ”€โ”€ services/                # Business logic services
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ fraudClient.js       # Fraud engine integration
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ keyRotation.js       # Cryptographic key rotation
โ”‚   โ”‚   โ”‚   โ””โ”€โ”€ redisClient.js       # Redis cache/pub-sub client
โ”‚   โ”‚   โ”œโ”€โ”€ ws/                      # WebSocket handlers
โ”‚   โ”‚   โ”‚   โ””โ”€โ”€ broadcaster.js       # Real-time event broadcaster
โ”‚   โ”‚   โ”œโ”€โ”€ scripts/
โ”‚   โ”‚   โ”‚   โ””โ”€โ”€ seedDemo.js          # Demo data seeding script
โ”‚   โ”‚   โ”œโ”€โ”€ config.js                # Configuration management
โ”‚   โ”‚   โ”œโ”€โ”€ index.js                 # Server entry point
โ”‚   โ”‚   โ””โ”€โ”€ swagger.js               # OpenAPI/Swagger docs
โ”‚   โ”œโ”€โ”€ package.json
โ”‚   โ”œโ”€โ”€ Dockerfile
โ”‚   โ””โ”€โ”€ .gitignore
โ”‚
โ”œโ”€โ”€ ๐Ÿ“‚ fraud/                        # Python FastAPI Fraud Detection Engine (ML Brain)
โ”‚   โ”œโ”€โ”€ src/
โ”‚   โ”‚   โ”œโ”€โ”€ features/                # Feature engineering
โ”‚   โ”‚   โ”‚   โ””โ”€โ”€ extractor.py         # Transaction feature extraction
โ”‚   โ”‚   โ”œโ”€โ”€ model/                   # Machine Learning Models
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ isolation.py         # Isolation forest anomaly detection
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ online.py            # Online learning pipeline
โ”‚   โ”‚   โ”‚   โ””โ”€โ”€ rules.py             # Rule-based fraud detection
โ”‚   โ”‚   โ”œโ”€โ”€ dependencies.py          # FastAPI dependency injection
โ”‚   โ”‚   โ”œโ”€โ”€ main.py                  # FastAPI application entry
โ”‚   โ”‚   โ”œโ”€โ”€ middleware.py            # Request/response middleware
โ”‚   โ”‚   โ”œโ”€โ”€ router.py                # API route definitions
โ”‚   โ”‚   โ””โ”€โ”€ schemas.py               # Pydantic request/response schemas
โ”‚   โ”œโ”€โ”€ requirements.txt             # Python dependencies
โ”‚   โ”œโ”€โ”€ Dockerfile
โ”‚   โ””โ”€โ”€ .gitignore
โ”‚
โ”œโ”€โ”€ ๐Ÿ“‚ k8s-manifests/                # Kubernetes Deployment
โ”‚   โ””โ”€โ”€ payshield-stack.yaml         # Complete K8s stack manifest
โ”‚
โ”œโ”€โ”€ ๐Ÿ“‚ payshield-demo/               # HTML Interactive Demo
โ”‚   โ””โ”€โ”€ index.html                   # Browser-based attack simulator
โ”‚
โ”œโ”€โ”€ ๐Ÿ“‚ postman/                      # API Testing Collection
โ”‚   โ””โ”€โ”€ collection.json              # Postman API endpoints
โ”‚
โ”œโ”€โ”€ ๐Ÿ“‚ requestly/                    # Requestly Browser Extension Rules
โ”‚   โ””โ”€โ”€ rules.json                   # Request tampering rules config
โ”‚
โ”œโ”€โ”€ ๐Ÿ“‚ test/                         # Integration Tests
โ”‚   โ””โ”€โ”€ integration.sh               # End-to-end test suite
โ”‚
โ”œโ”€โ”€ ๐Ÿณ docker-compose.yml            # Docker Compose orchestration
โ”œโ”€โ”€ ๐Ÿ“‹ render.yaml                   # Render.com deployment config
โ”œโ”€โ”€ README.md                        # This file
โ””โ”€โ”€ ๐Ÿ“š Documentation Files
    โ”œโ”€โ”€ cmd.md                       # Command reference
    โ”œโ”€โ”€ doc.md                       # Detailed documentation
    โ”œโ”€โ”€ guide.md                     # User guide
    โ”œโ”€โ”€ full_deployment_guide.md     # Deployment instructions
    โ”œโ”€โ”€ k8s_deployment_guide.md      # Kubernetes guide
    โ”œโ”€โ”€ railway_deployment_guide.md  # Railway.app guide
    โ”œโ”€โ”€ info.md                      # Project information
    โ”œโ”€โ”€ process.md                   # Development process
    โ””โ”€โ”€ [other documentation]

File Structure Legend

  • ๐Ÿ“‚ Directories - Logical service boundaries
  • ๐Ÿณ Docker Files - containerization configs
  • ๐Ÿ“‹ Config Files - deployment and build configuration
  • ๐Ÿ“š Documentation - guides and references

๐ŸŽฅ Demo Video

See PayShield in action intercepting a live API tampering attack:

๐Ÿ‘‰ Watch Demo on Google Drive


๐ŸŒ Using the Live Deployed App (User Flow for Judges)

The entire PayShield stack is deployed publicly on Render.com. No local setup required.

๐Ÿ”— Live Dashboard: https://payshield-dashboard.onrender.com/

Step-by-Step User Flow

Step 1: Open the Dashboard

  • Go to https://payshield-dashboard.onrender.com/
  • You will see the PayShield Intelligence System in dark mode with 4 stat cards at the top.
  • The "๐ŸŸข Connected" badge in the top right confirms a live WebSocket connection to the backend.

Step 2: Seed Demo Data (Inject 25 Transactions)

  • Click the "Seed Data ๐Ÿš€" button in the top header.
  • Within 5-8 seconds, you will see 25 transactions populate the Transaction Stream waterfall table in real time.
  • The stats cards will update automatically: Total Transactions = 25, Fraud Flagged = 1, Critical Alerts = 2.

Step 3: Explore the Transaction Stream

  • Each row shows: Transaction ID | Amount | Merchant | Risk Score | Status | Latency | Time
  • Green rows = Safe (SUCCESS). Red rows = Blocked (FRAUD_FLAGGED / TAMPERED).
  • Use the Search bar to filter by merchant name or transaction ID.

Step 4: View the Global Threat Map

  • Click the "Global Threat Map" tab.
  • You will see geo-located dots on the world map showing where the suspicious transactions originated (US, IN, SG, AU).
  • Color coding: ๐ŸŸก Medium Risk, ๐Ÿ”ด High Risk, ๐ŸŸฃ Critical / Tampered.

Step 5: Simulate a Live Attack (The Wow Moment)

  • Click the "โšก TEST TAMPER" button in the top-right header.
  • Alternatively, install the Requestly Chrome Extension and add a Modify Headers rule:
    • URL Contains: payment/initiate
    • Request Header: X-Requestly-Modified โ†’ true
  • The moment the tampered request hits the Gateway, a red banner appears at the top of the screen: โš ๏ธ TAMPER DETECTED โ€” 1 modified request intercepted
  • The transaction appears as ๐Ÿšจ BLOCKED in the stream with a 402 FRAUD_FLAGGED status.

Step 6: Analyze the Attack in the Replay Engine

  • Click the "Replay Engine" tab.
  • Select the red TAMPERED / BLOCKED transaction.
  • The Replay Engine visually reconstructs the entire lifecycle: Browser โ†’ [TAMPERED] โ†’ Gateway (Middleware Caught It) โ†’ ML Engine (Scored 1.0) โ†’ BLOCKED
  • This is the exact proof that PayShield caught the attack before it reached the database.

Step 7: Check the Right Sidebar

  • Risk Pipeline: Shows the last 20 transactions as color-coded dots. Look for the red dot (the tampered transaction).
  • System Latency Chart: Shows P50/P95 latency across the sessionโ€”should remain under 500ms SLA.
  • AI Model Status: Confirms the ML model version and accuracy metrics.

๐ŸŽฏ How to Test the Live Attack (For Judges)

๐Ÿ“Œ Important for Judges: Even if you have the Requestly extension installed, you would still need to manually create and configure the specific header injection rule. To avoid this friction, we strongly recommend watching the pre-recorded demo first:
๐ŸŽฅ Watch the full attack simulation on Google Drive
The video shows the exact Requestly rule setup, the header injection, the โš ๏ธ TAMPER DETECTED alert, and the live 402 FRAUD_FLAGGED block โ€” step by step.

If you still want to test it yourself, here's how:

Method 1: Import Our Requestly Rules (1 Click Setup)

We have pre-built the exact Requestly rule and saved it in the repo. No manual configuration needed.

  1. Install the Requestly Chrome Extension.
  2. Open Requestly โ†’ Click Import Rules โ†’ Upload the file requestly/rules.json from this repository.
  3. Open the live dashboard, click Seed Data ๐Ÿš€, then click any transaction to trigger an API call.
  4. Watch the โš ๏ธ TAMPER DETECTED red banner fire on the dashboard instantly.

Method 2: Manual Rule Setup

If you'd rather create the rule yourself in Requestly:

  • Rule Type: Modify Headers
  • URL Contains: payshield-gateway.onrender.com/api/v1/payment
  • Request Header: X-Requestly-Modified โ†’ value true

Method 3: Use The Dashboard's Built-In Button

No extension needed! Click the โšก TEST TAMPER button directly in the PayShield Dashboard header. It sends a pre-tampered payload straight to the Gateway and triggers the full detection flow instantly.


๐Ÿ”ฎ Future Roadmap

  • Behavioral Biometrics: Tracking typing speed and mouse movements to detect bots mimicking user behavior.
  • Graph Database Integration: Linking fraud rings together by mapping shared IP addresses and device fingerprints (Neo4j).
  • Automated Webhooks: Instant Slack/PagerDuty alerts for critical threshold breaches.

๐Ÿ‘ฅ Team Orbit

  • Pusalapati Devesh Reddy
  • M Tanusree Reddy
  • Nihal DR
Built with โค๏ธ by Team ORBIT for Hack-Nocturne 2.O
Stop trusting the client. Start proving it.

About

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors