Skip to content

abhay-2108/ComplainceAI

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

9 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸ›‘οΈ ComplianceAI β€” AI-Powered Anti-Money Laundering Platform

Intelligent transaction monitoring using Machine Learning, RAG, and Gemini AI β€” with Human-in-the-Loop review.


πŸ“Œ Problem Statement

Every year, over $2 trillion is laundered globally. Financial institutions spend $274 billion on compliance, yet 95% of money laundering goes undetected. Current compliance systems rely on static, rule-based thresholds (e.g., "flag transactions over $10,000") that criminals easily evade through structuring and smurfing. When alerts do trigger, human analysts spend 30–45 minutes per case manually reviewing transactions, cross-referencing policies, and writing reports β€” creating massive backlogs and fatigue.


πŸ’‘ Our Innovation

ComplianceAI replaces the entire manual compliance pipeline with an end-to-end AI-powered system:

🌳 ML-Based Detection (Not Rules)

A Random Forest classifier trained on 15 engineered features β€” including transaction velocity, cross-currency flags, implied exchange rates, and temporal patterns. Achieves 99% accuracy on the IBM AML dataset, catching patterns that rule-based systems miss.

🧠 RAG-Grounded AI Explanations

Every flagged transaction gets a professional compliance explanation from Google Gemini 2.5 Flash, grounded in real AML policy documents via Retrieval-Augmented Generation (RAG) using ChromaDB. No hallucinations β€” every explanation is backed by actual regulatory policy.

πŸ‘€ Human-in-the-Loop Review

AI recommends, humans decide. Compliance officers can Resolve or Escalate flagged violations with notes, creating a complete audit trail. The AI reduces analyst workload from 30 minutes to a quick review.

⚑ Distributed Processing

Celery task workers with MongoDB Atlas as the broker enable asynchronous batch processing. Each transaction is analyzed in ~3-5 seconds β€” ML prediction, policy retrieval, and LLM explanation β€” all in the background.


πŸ—οΈ Architecture

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”     REST API        β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚  React + TW  β”‚ ←─────────────────→ β”‚  FastAPI Server  β”‚
β”‚   Frontend   β”‚                     β”‚  (Python)        β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜                     β””β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                                              β”‚
                              .delay()        β”‚
                           (queue tasks)      ↓
                                     β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                                     β”‚  MongoDB Atlas   β”‚
                                     β”‚  (DB + Broker)   β”‚
                                     β””β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                                              β”‚
                                    picks up  β”‚  messages
                                              ↓
                                     β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                                     β”‚  Celery Worker   β”‚
                                     β”‚                  β”‚
                                     β”‚  1. ML Predict   β”‚
                                     β”‚  2. RAG Retrieve β”‚
                                     β”‚  3. Gemini API   β”‚
                                     β”‚  4. Save Results β”‚
                                     β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

🧰 Tech Stack

Layer Technology
Frontend React, Tailwind CSS, Recharts, Lucide Icons
Backend FastAPI (Python)
ML Model Random Forest β€” scikit-learn (150 trees, 15 features)
LLM Google Gemini 2.5 Flash
RAG ChromaDB + Sentence-Transformers + Gemini Embeddings
Task Queue Celery (solo pool)
Database MongoDB Atlas

πŸ“Š ML Model Details

  • Dataset: IBM AML Transaction Dataset (HI-Small_Patterns.txt)
  • Algorithm: Random Forest Classifier (150 estimators, max depth 20)
  • Accuracy: 99.07% | Precision: 0.99 / 0.98 | Recall: 0.99 / 0.98

Feature Engineering (15 features)

Feature Type
Log_Amount_Paid / Log_Amount_Received Log-transformed amounts
Implied_Exchange_Rate Received / Paid ratio
Is_Cross_Currency Boolean β€” different currencies
Same_Bank_Transfer Boolean β€” same bank sender/receiver
Sender_Tx_Frequency / Receiver_Tx_Frequency Account velocity
DayOfWeek, Is_Weekend, Time_of_Day Temporal features
From_Bank, To_Bank, Payment_Currency, Receiving_Currency, Payment_Format Label-encoded categoricals

πŸ“‚ Project Structure

ComplianceAI/
β”œβ”€β”€ backend/
β”‚   β”œβ”€β”€ agents/            # AI agents (monitoring, detection, explanation, RAG, reporting)
β”‚   β”œβ”€β”€ api/routes/        # FastAPI endpoints (violations, agents, predictions, RAG)
β”‚   β”œβ”€β”€ config/            # Settings and environment config
β”‚   β”œβ”€β”€ core/              # Celery app and startup logic
β”‚   β”œβ”€β”€ datasets/          # Transaction data files
β”‚   β”œβ”€β”€ ml/                # Random Forest model + predictor
β”‚   β”œβ”€β”€ models/            # Pydantic schemas
β”‚   β”œβ”€β”€ notebooks/         # Training notebooks
β”‚   β”œβ”€β”€ rag/               # Vector store + embedding model
β”‚   β”œβ”€β”€ scripts/           # Data loading utilities
β”‚   β”œβ”€β”€ security/          # Encryption helpers
β”‚   β”œβ”€β”€ database.py        # MongoDB connection layer
β”‚   β”œβ”€β”€ tasks.py           # Celery task definitions
β”‚   β”œβ”€β”€ main.py            # FastAPI application entry
β”‚   └── requirements.txt   # Python dependencies
β”œβ”€β”€ secure-ai-dashboard/
β”‚   └── src/
β”‚       β”œβ”€β”€ pages/         # React pages (Dashboard, Agents, Violations, etc.)
β”‚       β”œβ”€β”€ components/    # Reusable UI components
β”‚       └── services/      # API service layer
β”œβ”€β”€ .gitignore
└── README.md

πŸš€ Steps to Run the Project

Prerequisites

  • Python 3.10+
  • Node.js 18+
  • MongoDB Atlas account (or local MongoDB)
  • Google Gemini API Key

1. Clone the Repository

git clone https://github.com/abhay-2108/ComplainceAI.git
cd ComplainceAI

2. Backend Setup

# Create virtual environment
cd backend
python -m venv venv

# Activate (Windows)
venv\Scripts\activate

# Install dependencies
pip install -r requirements.txt

3. Configure Environment Variables

Create backend/.env:

MONGODB_URL=mongodb+srv://<user>:<password>@<cluster>.mongodb.net/?appName=Cluster0
DATABASE_NAME=compliance_ai
SECRET_KEY=<your-secret-key>
ENCRYPTION_KEY=<your-encryption-key>
GOOGLE_API_KEY=<your-gemini-api-key>
GEMINI_MODEL_NAME=gemini/gemini-2.5-flash
GEMINI_EMBEDDING_MODEL=models/gemini-embedding-001
CELERY_BROKER_URL=mongodb+srv://<user>:<password>@<cluster>.mongodb.net/celery_db
CELERY_RESULT_BACKEND=mongodb+srv://<user>:<password>@<cluster>.mongodb.net/celery_db

Create secure-ai-dashboard/.env:

VITE_API_BASE_URL=http://localhost:8000

4. Start the Backend Server

cd ..
python -m uvicorn backend.main:app --reload --port 8000

5. Start the Celery Worker (separate terminal)

backend\venv\Scripts\celery -A backend.core.celery_app worker --loglevel=info -P solo

6. Frontend Setup (separate terminal)

cd secure-ai-dashboard
npm install
npm run dev

7. Open the Application

Navigate to http://localhost:5173 in your browser.


πŸ“Έ Key Features

  • Dashboard β€” Real-time KPIs, risk trends, violation charts
  • AI Agents β€” 5 specialized agents + batch processing controls
  • Violations β€” Flagged transactions with AI explanations
  • Human Review β€” Resolve or Escalate with audit trail
  • RAG Policies β€” Policy-grounded AI explanations
  • Predictions β€” ML model output and confidence analysis
  • Audit Logs β€” Complete activity history

πŸ‘₯ Team

  • Mohita - Full Stack Developer & AI Engineer

  • Abhay Tiwari - Full Stack Developer & AI Engineer


πŸ“„ License

This project was built for HackFest 2.0.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors