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.
Prerequisites: Python 3.11+ and Node.js 18+
cd TrustTwin_AI
# One command to start everything:
chmod +x start-local.sh
./start-local.shThis script will:
- Create a Python virtual environment and install dependencies
- Run database migrations (SQLite โ no database install needed)
- Seed 10 RBI/SEBI regulations
- Start the backend on http://localhost:8000
- Install npm packages and start the frontend on http://localhost:3000
To stop:
./stop-local.shPrerequisites: Docker and Docker Compose
cd TrustTwin_AI
docker compose up --buildUses PostgreSQL with pgvector. App runs on http://localhost:3000.
| Service | URL |
|---|---|
| Frontend | http://localhost:3000 |
| Backend API | http://localhost:8000 |
| API Documentation | http://localhost:8000/docs |
โโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโ
โ Frontend โโโโโโถโ Backend โโโโโโถโ Database โ
โ React + TS โ โ FastAPI โ โ SQLite/PG โ
โ Tailwind โ โ 5 AI Agents โ โ โ
โ Port: 3000 โ โ Port: 8000 โ โ โ
โโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโ
| # | 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 |
- 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
- 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
- Impact simulation with financial loss prevention estimates
- Reputational damage scoring (1-10 scale)
- Operational cost savings analysis
- Interactive Chart.js visualizations
- Live activity feed (3-second polling)
- Aggregated statistics across all documents and incidents
- Recent incidents table with severity badges
- Agent status indicators
| 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 |
| 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 |
- 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
- React 18 + TypeScript
- Vite (build tool)
- Tailwind CSS 3.4
- Chart.js + react-chartjs-2
- React Router v6
- React Dropzone
- Axios
- Python 3.11+
- FastAPI
- SQLAlchemy 2.0
- Alembic (migrations)
- Pillow + imagehash (perceptual hashing)
- Pydantic v2
- Local: SQLite (zero-install)
- Docker: PostgreSQL 16 + pgvector
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
This project is a prototype built for demonstration purposes.