CaseForward | AI-Powered Case Management System
Built With
Description
CaseForward takes documents from multiple channels (web uploads, email, call transcripts), processes them through AI specialists who deliberate on findings, and generates action cards for attorney creating an efficient workflow that bridges the gap between AI-powered analysis and human legal expertise.
Motivation
Personal injury law firms face significant operational challenges:
- Document Overload: Attorneys handle hundreds of medical records, bills, police reports, and correspondence per case
- Information Silos: Critical case details are scattered across documents, making holistic case assessment difficult
- Time-Sensitive Deadlines: Statute of limitations, treatment gaps, and lien negotiations require constant vigilance
- Client Communication: Keeping clients informed while managing expectations requires empathy and consistency
- Valuation Complexity: Calculating settlement values involves medical specials, liens, policy limits, and liability assessments
Most traditional case management systems focus on storage and calendaring but fail to provide intelligent analysis and proactive recommendations. CaseForward AI addresses this gap by introducing an AI-first approach that mimics attorney decision-making while maintaining human oversight through a swipe-based approval system.
Objectives
- Intelligent Document Processing: Automatically extract, categorize, and analyze legal documents breaking it down into metadata using AI
- Multi-Agent Deliberation: Employ specialized AI agents that discuss cases from different perspectives (client relations, evidence analysis, settlement valuation)
- Actionable Recommendations: Generate attorney-reviewable action cards with confidence scores and reasoning
- Human-in-the-Loop Approval: Provide a swipe-based interface for attorneys to approve/reject AI recommendations
- Unified Case View: Combines case data, liens, and actions all in a single dashboard
- Scalable Architecture: Support multi-tenant deployment with Cloudflare R2 for document storage
Features
Core Platform Features
- Unified Document Intake: Upload documents via web, API, or batch processing with automatic deduplication
- Intelligent Categorization: AI-powered document classification (medical records, bills, police reports, etc.)
- Entity Extraction: Automatically extract patient names, providers, dates, etc
- Case Matching: Suggest case assignments based on client name, dates, and content similarity
AI Round Table System
- Multi-Agent Deliberation: Three specialized AI agents discuss each case/document
- Consensus-Based Recommendations: Agents reach agreement before generating action cards
- Contextual Analysis: Full case context (documents, liens, financials) provided to agents
- Confidence Scoring: Each recommendation includes a confidence score (0-1)
Attorney Workflow
- Swipe-Based Approval: Intuitive interface for quick approve/reject decisions
- Action Cards: Structured recommendations with title, description, type, and reasoning
- Feedback Loop: Rejections capture feedback for AI learning
Case Management
- Case Dashboard: Overview of all cases with status, financials, and pending actions
- Document Gallery: Visual browsing of case documents with AI summaries
Architecture
CaseForward AI follows a modern serverless architecture with clear separation between the client application, server APIs, AI orchestration layer, and storage services.
┌─────────────────────────────────────────────────────────────────────────────────┐
│ CASEFORWARD AI SYSTEM │
├─────────────────────────────────────────────────────────────────────────────────┤
│ │
│ CLIENT LAYER (Next.js) AI LAYER (Round Table) │
│ ────────────────────── ────────────────────── │
│ │
│ ┌──────────────────┐ ┌─────────────────────┐ │
│ │ Dashboard UI │◄────────────►│ Orchestrator │ │
│ │ (React 19) │ └──────────┬──────────┘ │
│ └──────────────────┘ │ │
│ ┌──────────┴──────────┐ │
│ ┌──────────────────┐ │ Round Table │ │
│ │ Swipe Interface │◄────────────►│ ┌───────┬───────┐ │ │
│ │ (Action Cards) │ │ │Client │Evidence│ │ │
│ └──────────────────┘ │ │ Guru │Analyzer│ │ │
│ │ ├───────┴───────┤ │ │
│ │ │ Settlement │ │ │
│ │ │ Valuator │ │ │
│ │ └───────────────┘ │ │
│ └─────────────────────┘ │
│ │
│ DATA LAYER (MongoDB) STORAGE LAYER │
│ ──────────────────── ───────────── │
│ │
│ ┌─────────┐ ┌─────────┐ ┌─────────────────────┐ │
│ │ Cases │ │Documents│◄─────────►│ Cloudflare R2 │ │
│ └─────────┘ └─────────┘ │ (raw files) │ │
│ └─────────────────────┘ │
│ ┌─────────┐ ┌─────────┐ │
│ │ Actions │ │ Liens │ ┌─────────────────────┐ │
│ └─────────┘ └─────────┘ │ Solana Devnet │ │
│ │ (audit hashes) │ │
│ ┌─────────┐ ┌─────────┐ └─────────────────────┘ │
│ │AuditLogs│ │Feedback │ │
│ └─────────┘ └─────────┘ │
│ │
└─────────────────────────────────────────────────────────────────────────────────┘
Client
The client side provides the attorney-facing interface for case management and action review.
Technologies Used: Next.js 16, React 19, TypeScript, Tailwind CSS, Lucide Icons
Key Components:
- Dashboard (
app/app/page.tsx): Overview of all cases and pending actions - Case Detail View (
app/app/case/[id]/): Full case information with document gallery - Swipe Container (
components/SwipeContainer.tsx): Approve/reject interface for action cards - Document Queue (
components/DocumentQueue.tsx): Pending document assignments - Activity Feed (
components/ActivityFeed.tsx): Real-time case activity stream
Server
The server handles API requests, database operations, and coordinates with AI services.
Technologies Used: Next.js API Routes, MongoDB/Mongoose, Auth0 Authentication
AI Layer
The AI layer implements a novel "Round Table" multi-agent deliberation system powered by Google Gemini.
Technologies Used: Vercel AI SDK, Google Gemini (2.5 Flash/Flash-Lite), Zod Schema Validation
Agent Roles:
| Agent | Role | Expertise |
|---|---|---|
| Orchestrator | Moderator | Routes tasks, sets context, synthesizes conclusions |
| Client Guru | Empathy Expert | Client communication, emotional intelligence, relationship management |
| Evidence Analyzer | Facts Expert | Document analysis, gap identification, inconsistency detection |
| Settlement Valuator | Numbers Expert | Case valuation, lien calculations, net recovery projections |
Deliberation Flow:
- Orchestrator introduces the topic with full case context
- Each specialist provides their perspective (parallel analysis)
- Optional follow-up rounds for consensus building
- Orchestrator synthesizes discussion into an Action Card
- Action Card returned with structured schema validation
Zero Trust Document Storage Architecture
┌─────────────────────────────────────────────────────────────────────────────┐
│ SECURITY ARCHITECTURE │
├─────────────────────────────────────────────────────────────────────────────┤
│ │
│ USER/CLIENT CLOUDFLARE EDGE │
│ ─────────── ──────────────── │
│ │
│ ┌──────────────┐ ┌──────────────────┐ │
│ │ Browser │──────────────►│ Cloudflare │ │
│ │ (holds │ HTTPS + │ Worker │ │
│ │ object key) │ Auth Token │ (IP-locked) │ │
│ └──────────────┘ └────────┬─────────┘ │
│ │ │
│ Object Key │ Internal Auth │
│ stays client-side │ + IP Allowlist │
│ ───────────────── ▼ │
│ ┌──────────────────┐ │
│ │ Cloudflare R2 │ │
│ │ Bucket │◄── NO PUBLIC ACCESS │
│ │ (raw files) │ │
│ └──────────────────┘ │
│ │
│ MONGODB (Metadata Only) │
│ ─────────────────────── │
│ │
│ ┌─────────────────────────────────────────────────────────┐ │
│ │ Documents Collection │ │
│ │ ───────────────────── │ │
│ │ • file.storagePath (object key reference) │ │
│ │ • file.hash (SHA-256 for deduplication) │ │
│ │ • extractedContent.text (extracted text only) │ │
│ │ • aiAnalysis.summary (AI-generated summary) │ │
│ │ • metadata (dates, amounts, entities) │ │
│ │ │ │
│ │ NO raw file bytes stored │ │
│ │ NO embedded images stored │ │
│ │ NO original PDFs stored │ │
│ └─────────────────────────────────────────────────────────┘ │
│ │
└─────────────────────────────────────────────────────────────────────────────┘
Key Security Principles
1. Client-Side Object Key Ownership
- Object keys are generated server-side but only returned to the authenticated client
- MongoDB stores only the key reference, not the file content
- To access a file, a user must possess both:
- Valid authentication session (Auth0)
- The specific object key for that document
- Even database compromise does not expose raw files—attackers would only get storage paths, not content
2. R2 Bucket Isolation
- No public access: The R2 bucket has zero public endpoints
- Worker-only access: Only the Cloudflare Worker can read/write to the bucket
- IP allowlisting: The Worker validates requests via:
X-Internal-Authheader with secret API key- Origin IP restrictions to the Next.js server
- No direct URLs: Files cannot be accessed via direct R2 URLs
Worker authentication check:
const auth = request.headers.get('X-Internal-Auth');
if (auth !== env.INTERNAL_API_KEY) {
return new Response('Unauthorized', { status: 401 });
}
3. MongoDB as Metadata-Only Store
The database intentionally stores no raw file content:
| Stored in MongoDB | NOT Stored in MongoDB |
|---|---|
Object key reference (file.storagePath) |
Raw PDF bytes |
| File hash for deduplication | Original document images |
| Extracted text content | Embedded file attachments |
| AI-generated summaries | Scanned page images |
| Parsed entities (names, dates, amounts) | Binary file content |
| Document metadata (size, type, upload date) | — |
This separation ensures:
- Database breaches are limited: Attackers get text/metadata, not original documents
- Faster queries: MongoDB isn't bloated with binary data
- Efficient AI processing: Text is readily available for analysis
- Compliance flexibility: Raw files can be purged from R2 independently
4. Hash-Based Deduplication
- Files are hashed (SHA-256) before upload
- Duplicate detection prevents storage of identical documents
- Hash stored in MongoDB; file stored once in R2
- Reduces storage costs and prevents redundant processing
const fileHash = await computeFileHash(arrayBuffer);
const existingDoc = await Document.findOne({ 'file.hash': fileHash });
if (existingDoc) {
return NextResponse.json({
success: false,
message: 'This file has already been uploaded',
documentId: existingDoc._id.toString(),
}, { status: 409 });
}
Installation
Prerequisites
- Node.js 18+
- MongoDB Atlas or local instance
- Google AI API Key (Gemini)
- Cloudflare R2 bucket + Worker
- (Optional) Solana devnet wallet
Steps
1. Clone the Repository
git clone https://github.com/your-org/CaseForwardAI
cd CaseForwardAI
2. Install Dependencies
cd caseforward
npm install
Dev Dependencies:
npm install -D @tailwindcss/postcss @types/formidable @types/node @types/react @types/react-dom eslint eslint-config-next tailwindcss tsx typescript
Dependencies:
npm install @ai-sdk/google @auth0/nextjs-auth0 @google/generative-ai @solana/web3.js ai bson dotenv formidable lucide-react mongodb mongoose next pdf-parse react react-dom zod
3. Configure Environment Variables
cp .env.example .env.local
Required variables:
# Database
MONGODB_URI=mongodb+srv://...
# Auth0
AUTH0_SECRET=...
AUTH0_BASE_URL=http://localhost:3000
AUTH0_ISSUER_BASE_URL=https://your-tenant.auth0.com
AUTH0_CLIENT_ID=...
AUTH0_CLIENT_SECRET=...
# Google AI
GOOGLE_GENERATIVE_AI_API_KEY=...
# Cloudflare R2
CF_WORKER_UPLOAD_URL=https://your-worker.workers.dev
INTERNAL_API_KEY=...
**4. Deploy Cloudflare Worker**
```bash
cd caseforward-worker
npx wrangler deploy
5. Run Development Server
cd caseforward
npm run dev
6. Access the Application
Open http://localhost:3000 in your browser.
Challenges Faced
1. Multi-Agent Coordination
Orchestrating multiple AI agents to have coherent discussions while avoiding contradictions or hallucinations required careful prompt engineering.
2. Legal Domain Expertise
Encoding accurate legal knowledge (lien priorities, statute of limitations, liability factors) into AI prompts without access to proprietary legal databases.
3. Document Diversity
Handling the wide variety of legal document formats (handwritten medical records, faxed police reports, scanned bills) with varying quality.
4. Real-Time Processing
Balancing the depth of AI analysis with response times acceptable for interactive use.
5. Human-AI Trust
Designing an interface that builds attorney trust in AI recommendations while maintaining appropriate skepticism.
6. Time
Designing and planning a complex architecture in A short period of time
7. Resources
Only having access to free/limited resources for things like Gemini API calls limited scale and speed of our project
Solutions Implemented
Multi-Agent Coordination
- Sequential speaking order with full history context
- Structured Action Card schema forcing consistent outputs
- Orchestrator synthesis step to resolve conflicts
Legal Domain Expertise
- Embedded lien knowledge base with priority rules
- Evidence checklist per case type
- Valuation methodology with multipliers and modifiers
Document Diversity
- PDF text extraction with fallback to OCR
- Entity extraction for key data points
- AI-powered document categorization
Real-Time Processing
- Gemini Flash-Lite for faster specialist responses
- Gemini 2.5 Flash for synthesis (quality-critical)
- Parallel agent opinions where possible
Confidence Calibration
- Zod schema enforces 0-1 confidence range
- Reasoning field explains confidence level
- Historical feedback integration (planned)
Impact
CaseForward AI addresses critical needs in legal operations:
Efficiency Gains
- Consistent client communication: Standardized, empathetic email drafts
- Proactive issue detection: AI flags missing documents and treatment gaps
Quality Improvements
- Multi-perspective analysis: Every case reviewed from client, evidence, and valuation angles
- Reduced oversight errors: AI catches inconsistencies humans might miss
- Accurate valuations: Data-driven settlement projections with lien awareness
Compliance & Accountability
- Feedback capture: Rejection reasons inform model improvements
- Transparent reasoning: AI explains every recommendation
- Zero Trust Security: Protecting client information
Scalability
- Handle more cases: AI augments paralegal capacity
- Consistent quality: Same analysis framework across all cases
- Cloud-native: Serverless architecture scales on demand
Roadmap Items
- [ ] OCR for scanned documents
- [ ] Email/fax intake integrations
- [ ] Mobile app with push notifications
- [ ] Advanced lien negotiation workflows
- [ ] Multi-tenant SaaS deployment
Learning
Throughout development, the team gained significant expertise:
AI/ML Advancements
- Multi-agent orchestration patterns
- Prompt engineering for legal domain
- Structured output generation with Zod schemas
- Vercel AI SDK for streaming responses
Full-Stack Development
- Next.js 16 App Router patterns
- MongoDB/Mongoose schema design
- Cloudflare Workers for edge processing
- Auth0 integration for authentication
Legal Domain Knowledge
- Personal injury case lifecycle
- Lien types and priority rules
- Settlement valuation methodology
- Medical records terminology
Architecture Patterns
- Serverless-first design
- Event-driven document processing
- Human-in-the-loop AI systems
- Immutable audit logging with blockchain
Tech Stack
| Category | Technologies |
|---|---|
| Frontend | Next.js 16, React 19, TypeScript, Tailwind CSS |
| Backend | Next.js API Routes, MongoDB, Mongoose |
| AI | Google Gemini 2.5, Vercel AI SDK, Zod |
| Storage | Cloudflare R2, Cloudflare Workers |
| Auth | Auth0 |
| Blockchain | Solana (devnet) |
| Dev Tools | ESLint, TSX, pnpm/npm |
Repository Structure
CaseForwardAI/
├── caseforward/ # Main Next.js application
│ ├── app/
│ │ ├── api/ # API routes
│ │ │ ├── intake/ # Document upload
│ │ │ ├── agent/ # AI orchestration
│ │ │ ├── actions/ # Action card management
│ │ │ ├── cases/ # Case CRUD
│ │ │ └── ...
│ │ └── app/ # Client pages
│ │ ├── case/[id]/ # Case detail view
│ │ ├── cases/ # Case list
│ │ └── chatbot/ # Chat interface
│ ├── components/ # React components
│ ├── lib/
│ │ ├── agents/ # AI Round Table system
│ │ │ ├── orchestrator.ts # Main entry point
│ │ │ ├── round-table.ts # Deliberation engine
│ │ │ ├── specialists/ # Agent implementations
│ │ │ └── services/ # Context services
│ │ ├── db/ # Database layer
│ │ │ ├── models/ # Mongoose schemas
│ │ │ └── extractors/ # PDF processing
│ │ ├── storage/ # R2 client
│ │ └── chain/ # Solana integration
│ └── public/
└── caseforward-worker/ # Cloudflare Worker
└── src/
└── index.ts # R2 upload handler
CaseForward AI - Intelligent Legal Case Management
Built With
- auth0
- cloudflare
- gemini
- mongodb
- next.js
- react
- tailwind
- typescript
Log in or sign up for Devpost to join the conversation.