Skip to content

About

๐Ÿฆ Unified Document Anomaly Detection & Autonomous Regulatory Compliance for Banks. Powered by 5 simulated AI agents.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

ย 

History

1 Commit

Folders and files

NameName
Last commit message
Last commit date
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

TrustTwin AI

Unified Document Anomaly Detection & Autonomous Regulatory Compliance for Banks

A full-stack web application prototype that merges real-time document anomaly detection with autonomous regulatory compliance workflows. Built with React, TypeScript, FastAPI, PostgreSQL/SQLite, and powered by 5 simulated AI agents.

Tech Stack Tech Stack Tech Stack Tech Stack Tech Stack


๐Ÿš€ Quick Start

Option 1: Run Locally (No Docker Required)

Prerequisites: Python 3.11+ and Node.js 18+

cd TrustTwin_AI

# One command to start everything:
chmod +x start-local.sh
./start-local.sh

This script will:

  1. Create a Python virtual environment and install dependencies
  2. Run database migrations (SQLite โ€” no database install needed)
  3. Seed 10 RBI/SEBI regulations
  4. Start the backend on http://localhost:8000
  5. Install npm packages and start the frontend on http://localhost:3000

To stop:

./stop-local.sh

Option 2: Run with Docker

Prerequisites: Docker and Docker Compose

cd TrustTwin_AI
docker compose up --build

Uses PostgreSQL with pgvector. App runs on http://localhost:3000.


๐ŸŒ Access Points

Service URL
Frontend http://localhost:3000
Backend API http://localhost:8000
API Documentation http://localhost:8000/docs

๐Ÿ— Architecture

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”     โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”     โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚   Frontend   โ”‚โ”€โ”€โ”€โ”€โ–ถโ”‚   Backend    โ”‚โ”€โ”€โ”€โ”€โ–ถโ”‚   Database   โ”‚
โ”‚  React + TS  โ”‚     โ”‚   FastAPI    โ”‚     โ”‚ SQLite/PG    โ”‚
โ”‚  Tailwind    โ”‚     โ”‚  5 AI Agents โ”‚     โ”‚              โ”‚
โ”‚  Port: 3000  โ”‚     โ”‚  Port: 8000  โ”‚     โ”‚              โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜     โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜     โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

๐Ÿค– Simulated AI Agents

# Agent Role
1 ๐Ÿ” Document Sentinel Scans uploaded documents, generates perceptual hashes, detects anomalies
2 ๐Ÿ“‹ Regulatory Watchdog Matches incidents with RBI/SEBI regulations via keyword analysis
3 โš–๏ธ Legal Decoder Generates Measurable Action Points (MAPs) from compliance templates
4 โœ… Process Compliance Assigns MAPs to departments, handles validation lifecycle
5 ๐Ÿ”ฎ Digital Twin Runs impact simulations estimating financial and reputational outcomes

๐Ÿ“„ Features

Document Upload & Anomaly Detection

  • Drag-and-drop PDF/image upload
  • Perceptual hash comparison against reference documents
  • Real-time forgery score with visual anomaly indicators
  • Automatic incident creation for tampered documents

Regulatory Compliance Pipeline

  • Automatic regulation matching from seeded RBI/SEBI rules
  • Rule-based MAP generation with department assignment (Legal, Branch, IT, Compliance)
  • Action point lifecycle: Pending โ†’ In Progress โ†’ Completed โ†’ Validated
  • Auto-validation after 5-second delay
  • Compliance certificate generation with digital signature

Digital Twin Sandbox

  • Impact simulation with financial loss prevention estimates
  • Reputational damage scoring (1-10 scale)
  • Operational cost savings analysis
  • Interactive Chart.js visualizations

Real-Time Dashboard

  • Live activity feed (3-second polling)
  • Aggregated statistics across all documents and incidents
  • Recent incidents table with severity badges
  • Agent status indicators

๐Ÿ—„ Database Schema

Table Description
documents Uploaded files with hash and anomaly status
incidents Security incidents from anomaly detection
regulations Seeded RBI/SEBI regulatory rules (10 entries)
incident_regulations Many-to-many incident โ†” regulation links
action_points Compliance tasks (MAPs) assigned to departments
simulation_results Digital Twin simulation outputs
activity_log Real-time agent activity feed

๐Ÿ”Œ API Endpoints

Method Endpoint Description
POST /api/upload Upload & scan document
GET /api/incidents List all incidents
GET /api/incidents/{id} Incident details with MAPs, regulations, simulations
POST /api/incidents/{id}/simulate Run Digital Twin simulation
GET /api/incidents/{id}/certificate Get compliance certificate
POST /api/action-points/{id}/complete Mark MAP complete โ†’ auto-validates after 5s
GET /api/dashboard/stats Dashboard statistics
GET /api/activity-log Live activity feed
GET /api/health Health check

๐ŸŽจ Design Theme

  • Primary Colors: Dark navy (#0f172a) + Gold accents (#d4a843)
  • Typography: Inter (Google Fonts)
  • UI Pattern: Glassmorphism with backdrop blur
  • Animations: Fade-in, slide-up, pulse, glow effects
  • Layout: Responsive sidebar + main content area

๐Ÿ›  Tech Stack

Frontend

  • React 18 + TypeScript
  • Vite (build tool)
  • Tailwind CSS 3.4
  • Chart.js + react-chartjs-2
  • React Router v6
  • React Dropzone
  • Axios

Backend

  • Python 3.11+
  • FastAPI
  • SQLAlchemy 2.0
  • Alembic (migrations)
  • Pillow + imagehash (perceptual hashing)
  • Pydantic v2

Database

  • Local: SQLite (zero-install)
  • Docker: PostgreSQL 16 + pgvector

๐Ÿ“ Project Structure

TrustTwin_AI/
โ”œโ”€โ”€ start-local.sh          # One-command local start
โ”œโ”€โ”€ stop-local.sh           # Stop all services
โ”œโ”€โ”€ docker-compose.yml      # Docker deployment
โ”œโ”€โ”€ .env                    # Environment variables
โ”œโ”€โ”€ README.md
โ”‚
โ”œโ”€โ”€ backend/
โ”‚   โ”œโ”€โ”€ Dockerfile
โ”‚   โ”œโ”€โ”€ requirements.txt
โ”‚   โ”œโ”€โ”€ alembic.ini
โ”‚   โ”œโ”€โ”€ alembic/
โ”‚   โ”‚   โ”œโ”€โ”€ env.py
โ”‚   โ”‚   โ””โ”€โ”€ versions/
โ”‚   โ”‚       โ””โ”€โ”€ 001_initial.py
โ”‚   โ”œโ”€โ”€ app/
โ”‚   โ”‚   โ”œโ”€โ”€ main.py         # FastAPI entry point
โ”‚   โ”‚   โ”œโ”€โ”€ config.py       # Settings
โ”‚   โ”‚   โ”œโ”€โ”€ database.py     # SQLAlchemy setup
โ”‚   โ”‚   โ”œโ”€โ”€ models.py       # ORM models
โ”‚   โ”‚   โ”œโ”€โ”€ schemas.py      # Pydantic schemas
โ”‚   โ”‚   โ”œโ”€โ”€ seed.py         # Regulation seed data
โ”‚   โ”‚   โ”œโ”€โ”€ agents/
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ document_sentinel.py
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ regulatory_watchdog.py
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ legal_decoder.py
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ process_compliance.py
โ”‚   โ”‚   โ”‚   โ””โ”€โ”€ digital_twin.py
โ”‚   โ”‚   โ””โ”€โ”€ routers/
โ”‚   โ”‚       โ”œโ”€โ”€ upload.py
โ”‚   โ”‚       โ”œโ”€โ”€ incidents.py
โ”‚   โ”‚       โ”œโ”€โ”€ dashboard.py
โ”‚   โ”‚       โ””โ”€โ”€ action_points.py
โ”‚   โ””โ”€โ”€ uploads/
โ”‚
โ””โ”€โ”€ frontend/
    โ”œโ”€โ”€ Dockerfile
    โ”œโ”€โ”€ nginx.conf
    โ”œโ”€โ”€ package.json
    โ”œโ”€โ”€ vite.config.ts
    โ”œโ”€โ”€ tailwind.config.js
    โ””โ”€โ”€ src/
        โ”œโ”€โ”€ App.tsx
        โ”œโ”€โ”€ api.ts
        โ”œโ”€โ”€ types.ts
        โ”œโ”€โ”€ index.css
        โ”œโ”€โ”€ components/
        โ”‚   โ”œโ”€โ”€ Layout.tsx
        โ”‚   โ”œโ”€โ”€ StatCard.tsx
        โ”‚   โ”œโ”€โ”€ IncidentTable.tsx
        โ”‚   โ”œโ”€โ”€ ActivityFeed.tsx
        โ”‚   โ”œโ”€โ”€ FileUpload.tsx
        โ”‚   โ”œโ”€โ”€ ForgeryResult.tsx
        โ”‚   โ”œโ”€โ”€ MAPTimeline.tsx
        โ”‚   โ”œโ”€โ”€ SimulationChart.tsx
        โ”‚   โ””โ”€โ”€ ComplianceCert.tsx
        โ””โ”€โ”€ pages/
            โ”œโ”€โ”€ Dashboard.tsx
            โ”œโ”€โ”€ Upload.tsx
            โ”œโ”€โ”€ IncidentList.tsx
            โ””โ”€โ”€ IncidentDetail.tsx

๐Ÿ“ License

This project is a prototype built for demonstration purposes.

About

๐Ÿฆ Unified Document Anomaly Detection & Autonomous Regulatory Compliance for Banks. Powered by 5 simulated AI agents.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages