Skip to content

AI-powered courtroom simulator transforming legal documents into immersive debates. Features Gemini 2.5 Flash agents, Veo 3 video generation, real-time WebSocket streaming, and comprehensive PDF reports on Google Cloud Platform.

License

Notifications You must be signed in to change notification settings

santanu2402/Legalmind

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

1 Commit
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

βš–οΈ LegalMind: AI-Powered Courtroom Simulator

LegalMind Banner

Where Artificial Intelligence Meets Justice

Next.js FastAPI Google Cloud Gemini 2.5 Veo 3 License

πŸš€ Live Demo β€’ πŸ“– Documentation β€’ πŸŽ₯ Video Demo β€’ πŸ“Š Architecture


🌟 Overview

LegalMind is a groundbreaking multi-agent AI system that transforms legal case documents into immersive, interactive courtroom simulations. Upload a case document, and watch as AI agentsβ€”powered by Google's Gemini 2.5 Flashβ€”conduct a realistic courtroom debate complete with Judge, Prosecutor, Defense Attorney, and Witnesses. The system generates cinematic verdict videos using Veo 3 and comprehensive PDF case reports.

✨ Key Features

  • πŸ“„ Intelligent Document Processing - Automatically extracts entities, charges, evidence, and timelines from legal documents
  • πŸ€– Multi-Agent AI Debate - Realistic courtroom proceedings with 5+ AI agents using Gemini 2.5 Flash
  • βš–οΈ Legal Database Integration - Cites actual IPC sections and U.S. Federal Law from BigQuery
  • 🎬 Cinematic Video Generation - Creates 720p HD courtroom videos with Veo 3
  • πŸ“Š Comprehensive Reports - Professional PDF case summaries with judicial theming
  • πŸ”΄ Real-Time Streaming - Watch debates unfold live via WebSocket connections
  • 🌐 Scalable Architecture - Microservices on Google Cloud Run with auto-scaling

🎯 Problem & Solution

The Problem

The legal system remains opaque and inaccessible. Law students struggle to visualize courtroom dynamics, citizens find legal proceedings confusing, and understanding judicial reasoning requires years of study.

Our Solution

LegalMind democratizes legal education by providing an interactive platform that:

  • Simulates realistic courtroom proceedings with AI agents
  • Demonstrates legal reasoning with actual law citations
  • Generates professional outputs (video + PDF reports)
  • Makes judicial processes transparent and comprehensible

πŸ—οΈ Architecture

System Overview

graph TB
    subgraph "Frontend - Next.js 14"
        FE[Web Application<br/>React + TypeScript]
    end
    
    subgraph "Backend Services - FastAPI"
        AG[API Gateway<br/>:8000]
        PS[Parser Service<br/>:8001]
        RA[Role Assignment<br/>:8002]
        AO[Agent Orchestrator<br/>:8003]
        VG[Video Generator<br/>:8004]
        RG[Report Generator<br/>:8005]
    end
    
    subgraph "AI Models"
        GEMINI[Gemini 2.5 Flash<br/>Multi-Agent Debate]
        VEO[Veo 3<br/>Video Generation]
    end
    
    subgraph "Infrastructure - GCP"
        FS[(Firestore)]
        BQ[(BigQuery<br/>Legal DB)]
        CS[Cloud Storage]
        PS_TOPIC[Pub/Sub]
    end
    
    FE -->|HTTP| AG
    FE -->|WebSocket| AO
    AG --> PS
    PS --> PS_TOPIC
    PS_TOPIC --> RA
    RA --> AO
    AO --> VG
    AO --> RG
    
    PS --> GEMINI
    AO --> GEMINI
    VG --> VEO
    
    PS --> FS
    RA --> FS
    AO --> FS
    RA --> BQ
    VG --> CS
    RG --> CS
    
    style FE fill:#E8F5E9
    style GEMINI fill:#4A90E2,color:#fff
    style VEO fill:#9B59B6,color:#fff
    style FS fill:#2ECC71,color:#fff
Loading

Workflow

sequenceDiagram
    participant User
    participant Frontend
    participant Parser
    participant RoleAssign
    participant Orchestrator
    participant VideoGen
    participant ReportGen
    
    User->>Frontend: Upload Document
    Frontend->>Parser: Process Document
    Parser->>Parser: Extract Entities
    Parser->>RoleAssign: Trigger Role Assignment
    RoleAssign->>RoleAssign: Assign AI Agents
    RoleAssign->>Orchestrator: Start Debate
    
    loop Courtroom Debate
        Orchestrator->>Frontend: Stream Messages
        Frontend->>User: Display Real-time
    end
    
    Orchestrator->>Orchestrator: Announce Verdict
    
    par Generate Outputs
        Orchestrator->>VideoGen: Create Video
        Orchestrator->>ReportGen: Create PDF
    end
    
    VideoGen->>Frontend: Video Ready
    ReportGen->>Frontend: PDF Ready
    Frontend->>User: Display Results
Loading

πŸš€ Quick Start

Prerequisites

  • Node.js 18+
  • Python 3.11+
  • Google Cloud Project
  • Docker (optional)

Installation

# Clone the repository
git clone https://github.com/yourusername/legalmind.git
cd legalmind

# Setup Backend
cd backend
pip install -r requirements.txt

# Setup Frontend
cd ../frontend
npm install

# Configure Environment
cp .env.example .env
# Edit .env with your credentials

# Run Services
./start_services.sh

Environment Variables

# Google Cloud
GOOGLE_CLOUD_PROJECT=your-project-id
GOOGLE_APPLICATION_CREDENTIALS=path/to/credentials.json

# Firestore
FIRESTORE_DATABASE=legalmind-db

# BigQuery
BIGQUERY_DATASET=legal_database

# Cloud Storage
STORAGE_BUCKET=legalmind-storage

# Frontend
NEXT_PUBLIC_API_URL=http://localhost:8000
NEXT_PUBLIC_WS_URL=ws://localhost:8003

πŸ’» Technology Stack

Frontend

  • Next.js 14 - React framework with App Router
  • TypeScript - Type-safe development
  • Tailwind CSS - Utility-first styling
  • WebSocket - Real-time communication

Backend

  • FastAPI - High-performance Python API framework
  • Pydantic - Data validation
  • Uvicorn - ASGI server

AI Models

  • Gemini 2.5 Flash - Multi-agent debate generation
  • Veo 3 - Cinematic video generation
  • Imagen 4 - Character image generation

Infrastructure

  • Google Cloud Run - Serverless containers
  • Firestore - NoSQL real-time database
  • BigQuery - Legal database (500+ IPC sections)
  • Cloud Storage - Video and PDF storage
  • Cloud Pub/Sub - Asynchronous messaging

πŸ“– Documentation


🎬 How It Works

  1. Upload Document - User uploads a legal case document (PDF/DOC/DOCX)
  2. Parse & Extract - AI extracts entities, charges, evidence (30s)
  3. Assign Roles - System assigns AI agents to courtroom roles (10s)
  4. Live Debate - Watch real-time courtroom proceedings (3-5 min)
  5. Generate Outputs - Create video and PDF report (2-3 min)
  6. View Results - Watch video and download comprehensive report

Total Time: 6-10 minutes per case


🌟 Key Innovations

1. Dynamic Multi-Agent System

  • Fixed Core Agents: Judge, Prosecutor, Defense, Accused, Investigator
  • Dynamic Agent Pool: 2-3 flexible agents for case-specific roles
  • Intelligent Role Assignment: Gemini 2.5 analyzes case and assigns roles

2. Legal Database Integration

  • 500+ IPC Sections stored in BigQuery
  • U.S. Federal Law provisions
  • Real-time Citation: Agents cite actual legal codes during debate

3. Cinematic Video Generation

  • Veo 3 Integration: State-of-the-art video generation
  • 720p HD Quality: Professional courtroom scenes
  • 8-Second Clips: Optimized for API quota and speed

4. Real-Time Streaming

  • WebSocket Architecture: Sub-100ms latency
  • Live Updates: Watch debates unfold naturally
  • Stage Progression: Visual indicators of debate phases

πŸ“Š Performance Metrics

Metric Value
Document Parsing 30 seconds
Role Assignment 10 seconds
Courtroom Debate 3-5 minutes
Video Generation 90 seconds
PDF Generation 60 seconds
Total End-to-End 6-10 minutes
WebSocket Latency <100ms
Concurrent Sessions 100+ (auto-scaling)

🎯 Use Cases

πŸ‘¨β€πŸŽ“ Law Students

  • Visualize courtroom dynamics
  • Learn legal argumentation
  • Understand judicial reasoning

βš–οΈ Legal Professionals

  • Analyze case strategies
  • Test evidence strength
  • Prepare for trials

πŸ‘¨β€πŸ« Educators

  • Interactive teaching tool
  • Demonstrate legal concepts
  • Facilitate discussions

πŸ‘₯ Citizens

  • Understand legal proceedings
  • Learn about rights
  • Demystify justice system

πŸ”’ Security & Privacy

  • βœ… Encryption at Rest & Transit - AES-256 + TLS 1.3
  • βœ… PII Redaction - Automatic removal of sensitive data
  • βœ… IAM Authentication - Service account-based access
  • βœ… Audit Logging - Complete access trail
  • βœ… Session Isolation - No data leakage between cases

πŸš€ Deployment

Docker Deployment

# Build all services
docker-compose build

# Start services
docker-compose up -d

# View logs
docker-compose logs -f

Google Cloud Run

# Deploy all services
./deploy_services.sh

# Or deploy individually
gcloud run deploy parser-service --source ./backend/parser-service
gcloud run deploy agent-orchestrator --source ./backend/agent-orchestrator
# ... etc

🀝 Contributing

We welcome contributions! Please see our Contributing Guide for details.

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/AmazingFeature)
  3. Commit your changes (git commit -m 'Add some AmazingFeature')
  4. Push to the branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

πŸ“„ License

This project is licensed under the MIT License - see the LICENSE file for details.


πŸ™ Acknowledgments

  • Google Cloud Platform - Infrastructure and AI models
  • Gemini 2.5 Flash - Multi-agent debate generation
  • Veo 3 - Cinematic video generation
  • FastAPI - High-performance backend framework
  • Next.js - Modern React framework

πŸ“ž Contact & Support


🌟 Star History

Star History Chart


Made with ❀️ by the LegalMind Team

βš–οΈ LegalMind - Democratizing Legal Education Through AI

⬆ Back to Top

About

AI-powered courtroom simulator transforming legal documents into immersive debates. Features Gemini 2.5 Flash agents, Veo 3 video generation, real-time WebSocket streaming, and comprehensive PDF reports on Google Cloud Platform.

Topics

Resources

License

Contributing

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published