- Problem Statement
- Live Demo
- How It Works
- Tech Stack
- How to Run Locally
- Project Structure
- Dataset
- Model Performance
- Known Limitations
- Team
- Contact
This project addresses PS1: AI-Driven Early Warning System for Internal & Privileged User Fraud.
Banking systems face severe vulnerabilities from privileged insiders β admins, branch staff, relationship managers, and IT teams β whose malicious actions blend seamlessly with normal operations and bypass traditional, externally-focused security perimeters.
ThreatLens is a real-time AI-powered Early Warning System that profiles behavioural baselines for individual privileged users, detects cross-silo anomalies (Core Banking, CRM, Treasury, Loans, Email) using an unsupervised Isolation Forest model, and deploys an Explainable AI Copilot (Gemini + Groq Llama 3.1) to translate every detected threat into an instant, actionable natural language incident summary β compressing SOC investigation time from hours to seconds.
| Link | |
|---|---|
| π Live App | https://ag235772-threat-lens.hf.space |
| π₯ Demo Video | [Insert YouTube Link here] |
Credentials for demo:
- SOC Analyst View β navigate to the Fraud Investigation Hub
- Manager View β navigate to the Manager Dashboard (kill-switch access)
- Trigger Live Events β use the Simulated Banking Portal to generate real-time anomalies through the full pipeline
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β THREATLENS PIPELINE β
β β
β ββββββββββββββββ ββββββββββββββββ ββββββββββββββββ ββββββββββββ β
β β Simulated β β FastAPI β β Isolation β β Gemini β β
β β Banking βββββΆβ Gateway βββββΆβ Forest βββββΆβ + Groq β β
β β Portal β β (Async) β β ML Engine β β XAI β β
β ββββββββββββββββ ββββββββββββββββ ββββββββββββββββ ββββββ¬ββββββ β
β Core Banking β β β β
β CRM | Treasury β anomaly_score β β
β Loans | Email MongoDB Atlas + is_anomaly β β
β β β β β
β βββββββΌββββββββββββββββββββββββββββββββββββββΌβββββββ β
β β React SOC Investigation Hub β β
β β ForceGraph2D | Kill Switch | XAI Copilot β β
β ββββββββββββββββββββββββββββββββββββββββββββββββββββ β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
- Ingest β The Simulated Banking Portal generates events across 5 silos; each event is POST'd to FastAPI with user ID, action type, amount, geo-location, and timestamp.
- Detect β The Isolation Forest model scores every event against the behavioural baseline. Outliers (anomaly score < 0) are flagged instantly.
- Explain β Gemini 2.5 Flash generates a full incident report. The Groq Llama 3.1 Copilot answers live SOC analyst questions in under 100ms.
- Contain β The Manager Dashboard's kill switch immediately revokes the suspicious user's session.
| Layer | Technology | Purpose |
|---|---|---|
| Frontend | React + Vite, ForceGraph2D | Real-time SOC dashboard, interactive threat network visualisation |
| Backend | Python 3.10, FastAPI, Uvicorn | Async REST API, ML inference pipeline, static file serving |
| Database | MongoDB Atlas, Motor (Async) | Flexible NoSQL event storage across multi-silo log structures |
| ML Engine | Scikit-learn (Isolation Forest), Pandas, NumPy, Joblib | Unsupervised anomaly detection; no labeled fraud data required |
| AI / XAI | Google Gemini 2.5 Flash, Groq Llama 3.1-8B | Natural language incident reports + real-time SOC Copilot Q&A |
| Deployment | Docker (Multi-Stage Build), Hugging Face Spaces | Single-container, zero-cost public hosting on port 7860 |
- Node.js 20+
- Python 3.10+
- A MongoDB Atlas free-tier cluster
- Gemini API key (get at aistudio.google.com)
- Groq API key (get at console.groq.com)
1. Clone the repository
git clone https://github.com/AUG235772/ThreatLens
cd threatlens2. Configure environment variables
# Create a .env file inside /backend
cp backend/.env.example backend/.envEdit backend/.env:
MONGO_URI=your_mongodb_atlas_connection_string
GEMINI_API_KEY_1=your_gemini_api_key
GEMINI_API_KEY_2=your_gemini_api_key_2 # optional β used for rotation
GEMINI_API_KEY_3=your_gemini_api_key_3 # optional β used for rotation
GROQ_API_KEY=your_groq_api_key3. Install backend dependencies and start the API
cd backend
pip install -r requirements.txt
uvicorn app.main:app --host 0.0.0.0 --port 8000 --reloadAPI will be live at
http://localhost:8000OpenAPI docs athttp://localhost:8000/docs
4. Install frontend dependencies and start the React app
# In a new terminal
cd frontend
npm install
npm run devApp will be live at
http://localhost:5173
# Build the image
docker build -t threatlens .
# Run with your environment variables
docker run -p 7860:7860 \
-e MONGO_URI=your_mongo_uri \
-e GEMINI_API_KEY_1=your_gemini_key \
-e GROQ_API_KEY=your_groq_key \
threatlensFull app (UI + API) accessible at
http://localhost:7860
threatlens/
β
βββ π backend/
β βββ π app/
β β βββ main.py β FastAPI app: routes, ML inference, XAI engine, MongoDB connection
β βββ requirements.txt β All Python dependencies
β βββ .env.example β Environment variable template
β
βββ π frontend/
β βββ π src/
β β βββ App.jsx β Root React component + routing
β β βββ π components/ β SOC Investigation Hub, Manager Dashboard, Simulated Portal
β β βββ π pages/ β Page-level views
β βββ package.json
β βββ vite.config.js
β
βββ π ml_engine/
β βββ π models/
β β βββ isolation_forest.pkl β Trained Isolation Forest model (Joblib)
β β βββ le_action.pkl β LabelEncoder for action_type feature
β β βββ le_geo.pkl β LabelEncoder for geo_location feature
β βββ model_training.ipynb β Full EDA + training pipeline notebook
β
βββ π assets/ β README screenshots (add yours here)
β
βββ Dockerfile β Multi-stage build (Node 20 β Python 3.10-slim)
βββ README.md
All data is 100% synthetic, generated by Team Dhurandhars using the training notebook at /ml_engine/model_training.ipynb.
| Property | Value |
|---|---|
| Total Events | 6,000 |
| Normal Events (95%) | 5,700 |
| Anomalous Events (5%) | 300 |
| Systems Covered | Core Banking, CRM, Treasury, Loans, Email |
| Simulated Employees | 10 privileged users across 5 departments |
| Simulation Period | 30 days |
| Reproducibility Seed | SEED = 42 |
Features per event:
| Feature | Type | Description |
|---|---|---|
amount_inr |
Float | Transaction amount in Indian Rupees |
is_business_hours |
Binary | 1 if event occurred 9amβ6pm MonβFri |
hour_of_day |
Int (0β23) | Hour the event was triggered |
action_code |
Encoded Int | LabelEncoded action type (20 possible actions) |
geo_code |
Encoded Int | LabelEncoded geographic location |
Normal profile: Business hours Β· Domestic geo (Mumbai, Delhi, Bangalore) Β· Routine actions (LOGIN_SUCCESS, VIEW_RECORD, DOMESTIC_TRANSFER) Β· Moderate INR amounts
Anomalous profile injected: Off-hours Β· Foreign geo (Moscow, Beijing, Dubai, Lagos) Β· Suspicious actions (BULK_EXPORT, UNAUTHORIZED_API_CALL, MASS_RECORD_ACCESS) Β· Extreme amounts
No real bank data was used at any stage.
| Metric | Value |
|---|---|
| Algorithm | Isolation Forest |
| n_estimators | 100 |
| contamination | 0.05 (5%) |
| Training Set Size | 6,000 events |
| XAI Coverage | 100% of flagged anomalies receive a natural language incident summary |
| Inference Speed | Near-instantaneous (no GPU required) |
| Model Artefacts | isolation_forest.pkl Β· le_action.pkl Β· le_geo.pkl |
β οΈ Note: Results are on synthetic data. Performance on real-world banking data would require re-training on actual institutional event logs with real behavioural baselines.
-
Synthetic data only β The system relies on simulated event sequences rather than live enterprise event streams (e.g., Apache Kafka). All employee activity is synthetically generated and does not represent real bank telemetry.
-
External LLM APIs β XAI features depend on Gemini and Groq APIs, which are subject to rate limiting (mitigated via 3-key rotation). These external APIs are not suitable for production environments containing real customer PII due to data privacy constraints.
-
Single-container deployment β The current architecture is a single Docker container on Hugging Face Spaces. Production would require independent microservices, dedicated scaling, SSO/Active Directory authentication, and compliance-grade audit logging.
-
No auto-retraining β The Isolation Forest is trained on a fixed dataset. User behavioural drift over time would require periodic retraining pipelines in production.
-
No authentication β The SOC dashboard has no user login (acceptable for POC demonstration; not suitable for production deployment).
| Name | Role | Responsibilities |
|---|---|---|
| Aditya Gupta | ML Lead | Isolation Forest training pipeline, synthetic dataset generation, model artefacts, anomaly scoring integration |
| Dev Parmar | Backend Developer | FastAPI architecture, MongoDB Atlas integration, XAI engine (Gemini + Groq), Docker multi-stage deployment |
| Yash Jani | Frontend Developer | React SPA (Vite), Simulated Banking Portal, SOC Investigation Hub, ForceGraph2D threat network visualisations |
| Het Patel | Domain Research | PS1 analysis, insider fraud typologies, banking compliance requirements, documentation (D1, D3, D4) |
| Team Name | DHURANDHARS |
| Project | ThreatLens |
| Institute | ITM SLS Baroda University |
| Hackathon | iDEA 2.0 β Phase 2 Submission |
| Problem Statement | PS1: AI-Driven Early Warning System for Internal & Privileged User Fraud |
Made with β€οΈ by Team Dhurandhars for iDEA 2.0
Detect. Explain. Contain.



