AI-powered image tampering detection system for insurance claim fraud prevention. Built for Contoso Insurance.
Automatically analyzes customer-submitted images for manipulation, metadata anomalies, duplicates, AI-generated content, and claim-description inconsistencies before claim adjudication.
Image Upload
│
▼
┌─────────────────────────────────────────────┐
│ Phase 1: Classical Detection (parallel) │
│ ├── Tampering (ELA, noise, JPEG, CNN, UNet)│
│ ├── Metadata (EXIF, GPS, timestamps) │
│ ├── Duplicate (pHash, CLIP, FAISS) │
│ ├── Document (OCR, font, region edits) │
│ └── AI-Generated (GAN, diffusion, CLIP) │
└─────────────────┬───────────────────────────┘
│
(skip if all scores < 0.15)
│
┌─────────────────▼───────────────────────────┐
│ Phase 2: LLM Enhancement (parallel) │
│ ├── Visual Analysis (GPT-4o vision) │
│ ├── Claim-Image Consistency (GPT-4o) │
│ └── Invoice Validation (GPT-4o text) │
└─────────────────┬───────────────────────────┘
│
┌─────────────────▼───────────────────────────┐
│ Phase 3: LLM-as-Judge (GPT-4o) │
│ Chain-of-thought reasoning over all evidence│
│ → risk score, confidence, recommended action│
└─────────────────┬───────────────────────────┘
│
┌─────────────────▼───────────────────────────┐
│ Phase 4: Explanation (GPT-4o-mini) │
│ Context-aware narrative for claim adjusters │
└─────────────────────────────────────────────┘
Background (every 6h):
└── Cross-claim fraud ring detection (batch)
| Layer | Technology |
|---|---|
| Backend | Python 3.12, FastAPI, SQLAlchemy (async), Celery |
| Frontend | Next.js 16, React 19, ShadCN UI, Tailwind CSS, TanStack Query |
| Database | PostgreSQL 16 |
| Cache/Queue | Redis 7 |
| LLM | Azure OpenAI GPT-4o (vision + reasoning), GPT-4o-mini (explanations) |
| ML Models | EfficientNet, CLIP ViT-B/32, FAISS, imagehash |
| Azure | Blob Storage, Document Intelligence, Container Apps |
| Local Dev | Docker Compose, Azurite |
- Docker and Docker Compose
- Node.js 20+
- Python 3.12+
git clone <repo-url>
cd temper-me
cp .env.example .env
# Edit .env with your Azure credentials (optional for local dev)docker-compose up -dThis starts PostgreSQL, Redis, Azurite, the FastAPI backend (port 8000), a Celery worker, and the Next.js frontend (port 3000).
make migrate- Frontend: http://localhost:3000
- Backend API: http://localhost:8000/api/v1/health
- API Docs: http://localhost:8000/docs
# Backend
cd backend
pip install -r requirements.txt
uvicorn app.main:app --reload --port 8000
# Frontend (separate terminal)
cd frontend
npm install
npm run devcurl -X POST http://localhost:8000/api/v1/claims/analyze \
-H "Content-Type: application/json" \
-d '{
"claim_id": "CLM-2026-001",
"image_url": "https://example.com/claim-photo.jpg",
"claim_type": "motor_accident",
"claim_description": "Rear-end collision on highway, major bumper damage",
"claimed_amount": 85000
}'{
"analysis_id": "uuid",
"claim_id": "CLM-2026-001",
"risk_score": 0.82,
"risk_category": "high",
"confidence": 0.88,
"recommended_action": "flag_for_SIU",
"tampered": true,
"duplicate_found": false,
"metadata_suspicious": true,
"ai_generated": false,
"module_scores": {
"tampering": 0.87,
"metadata": 0.45,
"duplicate": 0.0,
"document": null,
"ai_generated": 0.12
},
"llm_analysis": {
"visual_integrity_score": 0.78,
"claim_consistency_score": 0.35,
"judge_reasoning": "ELA and CNN both flag the bumper region...",
"key_evidence": [
{"module": "claim_consistency", "finding": "Severity mismatch", "impact": "high"}
]
},
"explanation": {
"summary": "High risk of fraud detected. Image shows editing near the damage area...",
"action_items": ["Request original photo", "Cross-verify with garage estimate"],
"key_findings": ["Compression inconsistency near bumper", "EXIF metadata stripped"]
},
"tamper_regions": [
{"x1": 120, "y1": 88, "x2": 360, "y2": 238, "confidence": 0.92, "source_module": "tampering.ela"}
],
"processing_time_ms": 8400,
"llm_used": true
}| Method | Path | Description |
|---|---|---|
POST |
/api/v1/claims/analyze |
Analyze a single claim image |
GET |
/api/v1/claims |
List claims (paginated, filterable) |
GET |
/api/v1/claims/{claim_id} |
Get full analysis for a claim |
GET |
/api/v1/claims/{claim_id}/report |
Export analysis report (JSON) |
POST |
/api/v1/bulk/analyze |
Submit batch of claims |
GET |
/api/v1/bulk/{batch_id}/status |
Check batch progress |
GET |
/api/v1/health |
System health check |
| Sub-detector | Technique | What it catches |
|---|---|---|
| ELA | Error Level Analysis | Spliced regions, local retouching |
| Noise | Block-wise variance | Copy-move, inconsistent noise patterns |
| JPEG | Quantization table analysis | Double compression, re-saved edits |
| CNN | EfficientNet backbone | General forgery classification |
| U-Net | Edge + color inconsistency | Pixel-level tamper localization |
Extracts and validates EXIF data: timestamps, GPS coordinates, camera make/model, editing software traces. Flags stripped metadata, future dates, location mismatches, and Photoshop signatures.
Computes perceptual hashes (pHash, dHash, aHash) and CLIP embeddings for each image. FAISS index enables sub-second similarity search across all previously analyzed claims.
Uses Azure Document Intelligence for OCR on invoices and receipts. Analyzes font consistency across text regions and applies ELA specifically to text areas to detect altered amounts or dates.
Combines FFT spectral analysis (GAN checkerboard artifacts), a HuggingFace diffusion model detector, and CLIP embedding statistics to identify synthetic or AI-edited content.
| Component | Model | Purpose |
|---|---|---|
| Visual Analysis | GPT-4o (vision) | Shadow/lighting/perspective inconsistencies |
| Claim Consistency | GPT-4o (vision) | Description vs. image mismatch (exaggerated claims) |
| Invoice Validation | GPT-4o (text) | Treatment-diagnosis alignment, pricing anomalies |
| Judge | GPT-4o (text) | Chain-of-thought synthesis of all evidence |
| Explanation | GPT-4o-mini | Human-readable narrative for adjusters |
| Cross-Claim | GPT-4o (batch) | Fraud ring detection across claim clusters |
Cost optimization: ~60-70% of clean claims skip LLM entirely. Image downscaling saves ~65% on vision tokens. Redis caching for repeated invoice patterns.
temper-me/
├── backend/
│ ├── app/
│ │ ├── main.py # FastAPI app
│ │ ├── config.py # Pydantic Settings
│ │ ├── api/v1/ # API route handlers
│ │ ├── models/ # SQLAlchemy ORM (12 tables)
│ │ ├── schemas/ # Pydantic request/response models
│ │ ├── services/
│ │ │ ├── orchestrator.py # 4-phase pipeline
│ │ │ ├── image_loader.py # Download + validate
│ │ │ └── risk_aggregator.py # Deterministic fallback scorer
│ │ ├── modules/
│ │ │ ├── base.py # BaseDetectionModule ABC
│ │ │ ├── tampering/ # ELA, noise, JPEG, CNN, U-Net
│ │ │ ├── metadata/ # EXIF, GPS, timestamps, software
│ │ │ ├── duplicate/ # pHash, CLIP, FAISS
│ │ │ ├── document/ # OCR, font analysis, region edits
│ │ │ ├── ai_generated/ # GAN, diffusion, CLIP synthetic
│ │ │ └── explainability/ # Risk scorer, reasons, visualizer
│ │ ├── llm/
│ │ │ ├── client.py # Azure OpenAI (retry, circuit breaker)
│ │ │ ├── visual_analysis.py # GPT-4o vision forensics
│ │ │ ├── claim_consistency.py# Claim vs. image check
│ │ │ ├── invoice_validation.py
│ │ │ ├── judge.py # LLM-as-Judge synthesis
│ │ │ ├── explanation.py # GPT-4o-mini narrative
│ │ │ ├── cross_claim.py # Fraud ring detection
│ │ │ ├── cache.py # Redis response cache
│ │ │ └── prompts/ # Versioned prompt templates
│ │ ├── storage/ # Azure Blob + PostgreSQL
│ │ └── workers/ # Celery tasks
│ ├── alembic/ # Database migrations
│ ├── tests/
│ ├── Dockerfile
│ └── requirements.txt
├── frontend/
│ ├── src/
│ │ ├── app/ # Next.js App Router pages
│ │ ├── components/ # ShadCN UI + custom components
│ │ ├── lib/ # API client, types, utils
│ │ └── hooks/ # React Query hooks
│ ├── Dockerfile
│ └── package.json
├── docker-compose.yml
├── Makefile
└── .env.example
12 tables covering the full claim analysis lifecycle:
claims— Claim reference, type, description, amountclaim_images— Image records with blob paths and file hashesanalysis_results— Top-level risk scores and flags per imagemodule_results— Per-module/sub-detector scores (JSONB details)tamper_regions— Detected tampered bounding boxesexplanations— Human-readable reasons with severity levelsduplicate_matches— Similarity records between image pairsimage_hashes— Perceptual hashes + CLIP embeddingsaudit_logs— Full compliance audit trailbulk_batches— Batch job trackingllm_call_logs— Every LLM call: tokens, latency, cost, prompt versionfraud_ring_alerts— Cross-claim pattern detection results
All configuration via environment variables (see .env.example):
# Required for full functionality
DATABASE_URL=postgresql+asyncpg://...
REDIS_URL=redis://...
AZURE_STORAGE_CONNECTION_STRING=...
LLM_AZURE_ENDPOINT=https://...openai.azure.com
LLM_AZURE_API_KEY=...
# Optional tuning
LLM_ENABLED=true # Global LLM kill switch
LLM_SHORT_CIRCUIT_THRESHOLD=0.15 # Skip LLM below this score
LLM_TIMEOUT_SECONDS=15 # Per-call timeout
LLM_CACHE_TTL_SECONDS=3600 # Redis cache TTLmake up # Start all Docker services
make down # Stop all services
make dev # Start with logs attached
make build # Rebuild containers
make migrate # Run database migrations
make test # Run backend tests
make lint # Lint backend codeMIT