Skip to content

rajantripathi/cash-for-crash

Repository files navigation

Cash for Crash: Graph-Based Insurance Fraud Detection

A modern fraud detection system using Graph Neural Networks (GNNs), RAG-powered explainability, and multi-agent investigation workflow.

Architecture

┌─────────────────────────────────────────────────────────────┐
│                        User Interface                        │
│  Network Visualization (Viz.js) + Risk Dashboard + Chat      │
└─────────────────────────────────────────────────────────────┘
                              ↓
┌─────────────────────────────────────────────────────────────┐
│                         API Layer                            │
│  FastAPI + WebSocket (real-time updates)                     │
└─────────────────────────────────────────────────────────────┘
                              ↓
┌─────────────────────────────────────────────────────────────┐
│                    Multi-Agent Orchestrator                  │
│  LangGraph coordinates: Network Analyst + Pattern Matcher    │
└─────────────────────────────────────────────────────────────┘
                              ↓
┌─────────────────────────────────────────────────────────────┐
│                      Analysis Layer                          │
│  ┌─────────────┐  ┌──────────────┐  ┌──────────────┐        │
│  │ GNN Engine  │  │Graph Database│  │ RAG System   │        │
│  │(PyG)        │  │ (Neo4j)      │  │(ChromaDB)    │        │
│  └─────────────┘  └──────────────┘  └──────────────┘        │
└─────────────────────────────────────────────────────────────┘

Features

  • GNN-based Fraud Detection: GraphSAGE/GAT models for network-aware fraud scoring
  • Implicit Link Discovery: Detect hidden connections between entities
  • RAG-Powered Explainability: Contextual explanations from historical cases
  • Multi-Agent Investigation: Automated dossier generation
  • Real-time Processing: <500ms latency per claim
  • Privacy-First: GDPR/CCPA compliant by design

Quick Start

Using Docker Compose

cp .env.example .env
docker-compose up -d

Local Development

# Install dependencies
python -m venv venv
source venv/bin/activate
pip install -r requirements.txt

# Start Neo4j (using Docker)
docker run -d \
  --name neo4j \
  -p 7474:7474 -p 7687:7687 \
  -e NEO4J_AUTH=neo4j/ghost123 \
  neo4j:5.15-community

# Start ChromaDB
docker run -d --name chromadb -p 8001:8000 chromadb/chroma:0.4.22

# Run API
uvicorn backend.api.main:app --reload

API Endpoints

# Score a claim
curl -X POST http://localhost:8000/api/v1/claims/score \
  -H "Content-Type: application/json" \
  -d @data/sample_claim.json

# Get investigation details
curl http://localhost:8000/api/v1/investigation/{claim_id}

# Get network visualization data
curl http://localhost:8000/api/v1/network/{claim_id}

Graph Schema

Node Types:

  • Claim (amount, date, type, status)
  • Driver (age, license_hash, risk_score)
  • Vehicle (make, model, year, vin_hash)
  • Location (lat, lon, geohash)
  • RepairShop (name_hash, address, tier)
  • Witness (contact_hash, relationship)

Edge Types:

  • Claim → Driver (filed_by)
  • Claim → Vehicle (involved)
  • Claim → Location (occurred_at)
  • Claim → RepairShop (assigned_to)
  • Driver → Vehicle (owns)
  • RepairShop → RepairShop (implicit similarity)

Testing

# Unit tests
pytest tests/ -v

# With coverage
pytest tests/ --cov=backend --cov-report=html

# Integration tests
pytest tests/integration/ -v

Development

# Format code
black backend/ tests/
ruff check backend/ tests/

# Type check
mypy backend/

# Run Jupyter
docker-compose up jupyter
# Open http://localhost:8888

License

MIT

About

Graph-based insurance fraud detection system using GNNs, RAG, and multi-agent systems

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors