Inspiration

Have you ever submitted an insurance/medical claim and waited days for approval? We've been there. Behind the scenes, claim processors spend 5-10 hours daily manually entering data from documents—tedious, error-prone, and expensive work that frustrates everyone involved.

We thought: What if AI could do the heavy lifting? That's where CAMEL-AI's multi-agent system comes in. We wanted to build something that actually solves a real problem—automating claim processing from document upload to approval, while keeping security tight with proper role-based access control.

What it does

ClaimSphere AI turns a 10-minute manual process into 30 seconds of automated intelligence using a sophisticated CAMEL-AI multi-agent system:

For users submitting claims:

  • Drag and drop claim documents (PDF, JPG, PNG)
  • AI-powered extraction - CAMEL-AI agents automatically extract key fields—names, dates, amounts, policy numbers using OLLAMA (phi3:mini) and ERNIE 5.0 Thinking
  • Review and correct extracted information if needed
  • Track claim status in real-time
  • AI Assistant - Ask questions in plain English: "What's my total approved amount?" Get concise, relevant answers with reasoning traces

For agents reviewing claims:

  • Prioritized review queue showing what needs attention
  • AI confidence scores for each extracted field
  • Gen AI Review - Role-playing AI agents (Reviewer + Approver) simulate human-like claim review with detailed assessments
  • One-click approve, deny, or request more info after AI review
  • Automatic duplicate claim detection with >85% accuracy
  • Comprehensive analytics dashboard

The smart stuff behind the scenes:

CAMEL-AI Multi-Agent System:

  • 8 Specialized AI Agents working together:
    • OCR Agent (PaddleOCR) - Document text extraction
    • Extraction Agent - Intelligent field extraction with reasoning
    • Validation Agent - Smart validation with explainable decisions
    • Fraud Detection Agent - Risk assessment with >85% accuracy
    • Duplicate Detection Agent - Prevents duplicate submissions
    • Query Agent - Natural language queries with concise answers
    • Review Agent - Role-playing Senior Claims Reviewer
    • Approval Agent - Role-playing Claims Approver

Role-Playing AI Review:

  • Two AI agents (Reviewer + Approver) simulate realistic claim review discussions
  • Multi-turn conversations for complex cases
  • Detailed assessments with key findings, concerns, and recommendations
  • Policy references and conditions for decisions
  • Confidence scores and reasoning traces

Auto-approval: Automatically approves 40-60% of low-risk claims

Fraud detection: Catches duplicates and suspicious patterns (>85% accuracy)

Natural language queries: Ask questions, get concise answers—no SQL needed. Powered by OLLAMA (phi3:mini) for fast, local processing

Complete audit trail: Everything logged for compliance

The impact:

  • 95% faster processing (10 min → 30 sec)
  • 60-70% cost reduction through automation
  • >95% accuracy in field extraction
  • >85% accuracy in duplicate detection
  • Explainable AI - Every decision comes with reasoning traces

Please refer for detailed project info and architecture - https://github.com/palsure/claimsphere-ai/blob/main/README.md

How we built it

Tech Stack:

Backend:

  • FastAPI + PostgreSQL (Railway)
  • CAMEL-AI Framework - Multi-agent orchestration system
  • OLLAMA - Local open-source LLM (phi3:mini) for fast, free AI processing
  • Baidu ERNIE 5.0 Thinking API for advanced AI processing (fallback)
  • PaddleOCR 3.x for document processing
  • JWT auth with role-based access control

Frontend:

  • Next.js 14 + TypeScript (Vercel)
  • React Context API for state management
  • Polished UI with dark/light mode support
  • Real-time claim status tracking
  • AI Assistant chat interface
  • Role-playing review interface

DevOps:

  • Railway (Backend + OLLAMA service)
  • Vercel (Frontend)
  • Docker containerization
  • Git-based CI/CD

Development Process:

We started with solid architecture planning - database design, API structure, and RBAC model. Then built the FastAPI backend with CAMEL-AI multi-agent system integration:

  1. Agent Architecture - Designed 8 specialized agents, each with a specific role
  2. OLLAMA Integration - Set up local LLM (phi3:mini) for fast, free AI processing
  3. Role-Playing System - Implemented CAMEL-AI role-playing framework for realistic claim review
  4. Query Agent - Built natural language query system with reasoning traces
  5. Frontend - Built Next.js frontend with role-based dashboards, AI Assistant, and role-playing review interface
  6. Testing & Optimization - Optimized prompts, reduced token usage, improved response times
  7. Deployment - Deployed to Railway (Backend + OLLAMA) and Vercel (Frontend)

Challenges we ran into

1. Memory Issue: PaddleOCR Segmentation Faults

Problem: PaddleOCR needs ~800MB RAM and can crash with segmentation faults on certain files, crashing the entire backend.

Solution:

  • Added comprehensive file validation before processing
  • Implemented timeout protection (30 seconds)
  • Added graceful error handling for segfaults
  • Made OCR optional via DISABLE_OCR environment variable
  • Added file size limits (max 50MB) and format validation

Lesson: Always validate inputs and handle C++ library crashes gracefully.

2. OLLAMA Timeout Issues

Problem: OLLAMA queries were timing out, even with increased timeouts.

Solution:

  • Optimized prompts to be ultra-concise (single line, minimal context)
  • Reduced max_tokens to 150-256 for faster responses
  • Limited context to 8 recent claims for queries
  • Set appropriate timeouts (90s for agents, 95s step timeout)
  • Used phi3:mini model for fastest performance
  • Added fallback to local answer generator if OLLAMA fails

Lesson: Model optimization is crucial - shorter prompts and lower token limits dramatically improve response times.

3. OCR Model Download Timeouts

Problem: PaddleOCR tried downloading huge models during deployment, causing timeouts.

Solution: Added explicit checks to prevent OCR initialization when disabled—stopping it before any memory allocation.

Lesson: Lazy initialization and feature flags are essential for cloud deployments.

4. RBAC for Natural Language Queries

Problem: How do you let users ask questions while ensuring they only see their own claims?

Solution: Built context-aware filtering that happens before OLLAMA processes the query, automatically scoping results based on user role. The Query Agent receives pre-filtered claims context.

Lesson: Security must be enforced at the data layer, not just the API layer.

5. Railway OLLAMA Connection Issues

Problem: Backend couldn't connect to OLLAMA service on Railway, even with environment variables set.

Solution:

  • Used load_dotenv(override=False) to prevent overriding Railway's environment variables
  • Added /env-check endpoint for debugging
  • Enhanced startup logging to show environment variables
  • Configured both private (ollama.railway.internal) and public URLs
  • Added comprehensive error handling and fallback mechanisms

Lesson: Environment variable loading can be tricky in cloud deployments - always verify with diagnostic endpoints.

6. AI Response Formatting

Problem: AI responses were showing raw JSON and long text, making them hard to read.

Solution:

  • Implemented text truncation (100-150 chars) for long responses
  • Added summary cards for key metrics (confidence, assessment)
  • Created collapsible sections for detailed reasoning
  • Improved visual hierarchy with better spacing and colors
  • Added item counts to section headers

Lesson: UX matters - even the best AI is useless if users can't understand the output.

Accomplishments that we're proud of

Production Deployment

  • Full production deployment on Railway (Backend + OLLAMA) + Vercel (Frontend)
  • Backend handles OCR errors gracefully without crashing
  • OLLAMA service running smoothly with phi3:mini model
  • All services healthy and monitored

95% Speed Improvement

  • Reduced claim processing from 10 minutes to 30 seconds—real, measurable impact
  • OLLAMA provides fast, local AI processing (no API costs)
  • Optimized prompts and token usage for maximum speed

Smart Automation that's Safe

  • 40-60% of claims auto-approve, but high-risk ones still get human review
  • Found the perfect balance between automation and safety
  • Role-playing AI agents provide human-like review for complex cases

OLLAMA-Powered Conversations

  • Users can ask "What's my total approved amount?" and get instant answers
  • Powered by OLLAMA (phi3:mini) for fast, free, local processing
  • Concise, relevant answers with reasoning traces and source citations
  • No API costs for queries!

Role-Playing AI Review

  • Two AI agents (Reviewer + Approver) simulate realistic claim review
  • Multi-turn discussions for complex cases
  • Detailed assessments with key findings, concerns, and recommendations
  • Policy references and conditions for every decision
  • Confidence scores and reasoning traces for transparency

Fraud Detection that Works

  • >85% accuracy catching duplicate claims
  • Spots both exact copies and variations
  • Explainable AI - shows why a claim is flagged

Enterprise Security

  • JWT auth, RBAC, and complete audit trails
  • Production-grade, not just a hackathon demo
  • Role-based data access enforced at the query level

Actually Usable Docs

  • Clear, concise guides that get anyone deployed in minutes
  • Comprehensive architecture documentation
  • Troubleshooting guides for common issues

Polished UI

  • Beautiful, modern interface with dark/light mode
  • AI Assistant with chat-like interface
  • Role-playing review with readable, formatted assessments
  • Responsive design that works on all devices

What we learned

CAMEL-AI Multi-Agent System

We learned how to build sophisticated multi-agent systems using CAMEL-AI:

  • Agent Orchestration - Coordinating multiple specialized agents
  • Role-Playing Framework - Creating realistic agent personas and conversations
  • ChatAgent Integration - Using CAMEL-AI's ChatAgent for intelligent processing
  • Reasoning Traces - Extracting and displaying AI reasoning for explainability
  • Error Handling - Graceful fallbacks when agents fail

OLLAMA Integration and Optimization

  • Local LLM Deployment - Setting up OLLAMA on Railway for free, local AI processing
  • Model Selection - Choosing phi3:mini for best speed/quality balance
  • Prompt Optimization - Ultra-concise prompts for faster responses
  • Token Management - Reducing max_tokens and context size for speed
  • Timeout Handling - Setting appropriate timeouts and fallback mechanisms
  • Connection Management - Handling Railway networking (private vs public URLs)

ERNIE 5.0 Thinking API Integration

  • Access Token Management - Setting up Baidu AI Studio API, managing tokens, handling rate limits
  • Thinking Mode - Using ERNIE's advanced reasoning capabilities
  • Fallback Strategies - Graceful degradation when ERNIE is unavailable
  • Cost Optimization - Caching responses and batching requests

PaddleOCR Setup and Memory Optimization

  • Initialization - Properly initializing PaddleOCR with minimal memory footprint
  • Format Handling - Processing different document formats (PDF, JPG, PNG)
  • Error Handling - Catching segmentation faults and other C++ library crashes
  • File Validation - Validating files before processing to prevent crashes
  • Optional OCR - Making OCR optional via environment variables for low-memory deployments

Building a Hybrid AI Pipeline

  • OCR + AI Extraction - Combining PaddleOCR (text extraction) with OLLAMA/ERNIE (intelligent understanding)
  • Structured Data Extraction - Converting unstructured OCR text to structured claim data
  • Validation with AI - Using AI for intelligent validation, not just rule-based
  • Explainable Decisions - Providing reasoning for every AI decision

Natural Language Queries with RBAC

  • Context-Aware Filtering - Filtering claims by user role before AI processing
  • Concise Answers - Generating short, focused responses (max 150 chars)
  • Source Citations - Showing which claims and fields were used
  • Reasoning Traces - Displaying how the AI arrived at answers
  • Query Optimization - Ultra-compact prompts, minimal token usage

Production Deployment of AI Services

  • Railway Deployment - Deploying backend and OLLAMA as separate services
  • Environment Variables - Proper handling of env vars in cloud deployments
  • Service Networking - Configuring private and public networking
  • Health Checks - Monitoring service health and availability
  • Error Recovery - Graceful handling of service failures
  • Cost Management - Using free/open-source solutions (OLLAMA) to reduce costs

UI/UX for AI Features

  • Chat Interface - Building intuitive chat UI for AI Assistant
  • Review Display - Formatting complex AI review data for readability
  • Text Truncation - Showing concise summaries with expandable details
  • Visual Hierarchy - Using cards, badges, and spacing for clarity
  • Dark/Light Mode - Supporting both themes for better UX

What's next for ClaimSphere AI - Automated Claim Processing Agent

Enhanced AI Capabilities

  • Advanced ML Fraud Detection - Deep learning models for pattern recognition
  • Computer Vision - Damage assessment from images
  • Predictive Analytics - Forecast claim trends and risks
  • Multi-language Support - Process claims in multiple languages

Mobile Experience

  • Native iOS/Android Apps - Mobile-first claim submission
  • Voice-based Submission - Submit claims via voice commands
  • Push Notifications - Real-time status updates

Enterprise Features

  • Multi-tenant Architecture - Support multiple insurance companies
  • White-label Solution - Customizable branding
  • Major Platform Integrations - Connect with existing insurance systems
  • Advanced Analytics - Custom dashboards and reporting

Notifications & Workflows

  • Email/SMS Alerts - Automated notifications for status changes
  • Bulk Upload - Process multiple claims at once
  • Appeal Workflow - Handle claim appeals and disputes
  • Custom Workflows - Configurable approval chains

Compliance & Scale

  • Blockchain Audit Trails - Immutable audit logs
  • Multi-language UI - Support for international users
  • Advanced RBAC - Fine-grained permissions
  • API Rate Limiting - Protect against abuse
  • Horizontal Scaling - Support millions of claims

AI Improvements

  • Fine-tuned Models - Custom models trained on insurance data
  • Continuous Learning - Models improve from feedback
  • Multi-modal AI - Process text, images, and voice together
  • Agent Collaboration - More sophisticated multi-agent workflows

Key Benefits of ClaimSphere AI

  • 95% faster processing - Reduce claim processing time from days to minutes
  • 60-70% cost reduction - Automate manual data entry and review
  • >95% accuracy - AI-powered extraction reduces human errors
  • >85% fraud detection - Catch duplicates and suspicious patterns
  • Complete audit trail - Every action logged for compliance
  • Scalable - Handle thousands of claims without hiring more staff

Built With

Share this project:

Updates