Skip to content

An AI-powered platform that transforms complex legal documents into clear, actionable insights using Google Cloud AI technologies.

Notifications You must be signed in to change notification settings

Harshad2321/Legal-AI-Simplifier

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

40 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Legal AI Simplifier - GenAI Exchange Hackathon

AI-Powered Legal Document Analysis Platform

Submission for GenAI Exchange Hackathon by Google Cloud

Live Demo Hackathon React TypeScript TailwindCSS Google Cloud


Hackathon Project Overview

Problem Statement: Legal documents are complex and inaccessible to the general public, creating barriers to understanding rights, obligations, and risks.

Our Solution: An AI-powered platform that transforms complex legal documents into clear, actionable insights using Google Cloud AI technologies.

Impact: Democratizing access to legal information and empowering individuals to make informed decisions.


Transform complex legal documents into clear, actionable insights with our AI-powered platform. Built for the GenAI Exchange Hackathon with enterprise-grade design and functionality.

Hackathon Submission Details

Competition Information

  • Event: GenAI Exchange Hackathon
  • Organizer: Google Cloud & Hack2Skill
  • Track: Professional Track
  • Team: Legal AI (Harshad Agrawal, Parth Kosthi, Krrish Talesara)

Problem Statement Alignment

Our solution addresses the critical need for accessible legal information by:

  • analysis using AI
  • barriers to legal understanding for general public
  • insights from legal contracts and agreements
  • access to legal expertise through AI-powered assistance

Google Cloud AI Integration

  • API - Advanced natural language processing for legal text analysis
  • AI - Machine learning models for risk assessment and clause classification
  • Run - Scalable backend deployment for document processing
  • Firebase - Real-time data synchronization and user management
  • BigQuery - Data analytics for legal document insights

Innovation Highlights

  • Understanding - Context-aware legal text processing
  • Visualization - Color-coded risk indicators with detailed explanations
  • Interface - Conversational AI for document-specific questions
  • Generation - Automated legal analysis summaries
  • UI - Enterprise-grade user experience design

Features

Core Capabilities

  • Document Analysis - Advanced AI-powered legal document processing
  • Risk Assessment - Intelligent clause risk evaluation with color-coded indicators
  • Clause Explorer - Interactive expandable interface for document navigation
  • Q&A Assistant - Modern chat interface with AI legal expert
  • Visual Dashboard - Beautiful animated metrics and data visualization
  • Report Generation - Professional downloadable analysis reports

Premium UI/UX

  • Drag & Drop Upload - Smooth file upload with real-time progress
  • Responsive Design - Mobile-first approach with TailwindCSS
  • Smooth Animations - Framer Motion micro-interactions
  • Glass Morphism - Modern premium visual effects
  • shadcn/ui Components - Consistent, accessible design system

Tech Stack

Frontend

  • React 18 + TypeScript - Modern component architecture
  • TailwindCSS - Utility-first styling with custom design tokens
  • shadcn/ui - Premium component library
  • Framer Motion - Smooth animations and transitions
  • Zustand - Lightweight state management
  • Recharts - Beautiful data visualization

Backend

  • FastAPI - High-performance Python web framework
  • Google Cloud Platform - Document AI + Vertex AI integration
  • PostgreSQL - Robust data persistence
  • Docker - Containerized deployment
  • Run - Serverless scaling

Quick Start for Team

Prerequisites

  • 18+ and npm
  • 3.9+ and pip
  • Git for version control

Clone & Setup

# Clone the repository
git clone https://github.com/Harshad2321/Legal-AI-Simplifier
cd Legal-AI-Simplifier

# Install frontend dependencies
cd frontend
npm install --legacy-peer-deps

# Install backend dependencies  
cd ../backend
pip install -r requirements.txt

Environment Configuration

# Backend environment
cd backend
cp .env.example .env
# Edit .env with your Google Cloud credentials

# Start backend server
python -m uvicorn app.main:app --reload --port 8080

Start Development

# Start frontend (in new terminal)
cd frontend
npm start
# Opens at http://localhost:3000

Deploy to GitHub Pages

# Build and deploy to GitHub Pages
cd frontend
npm run deploy

Live Demo: https://harshad2321.github.io/Legal-AI-Simplifier

Development Workflow

Team Collaboration

  1. Create feature branch: git checkout -b feature/your-feature-name
  2. Make changes and test locally
  3. Commit with description: git commit -m "Add feature description"
  4. Push branch: git push origin feature/your-feature-name
  5. Create Pull Request for team review

Code Standards

  • TypeScript - Strict typing for reliability
  • Prettier - Consistent code formatting
  • Component-driven - Reusable UI components
  • Mobile-first - Responsive design approach

Project Structure

Legal-AI-Simplifier/
 frontend/                 # React TypeScript app
    src/
       components/       # Reusable UI components  
       pages/           # Main application pages
       services/        # API integration layer
       store/           # Zustand state management
       types/           # TypeScript definitions
    public/              # Static assets

 backend/                  # FastAPI Python server
    app/
       routers/         # API endpoint definitions
       services/        # Business logic layer
       schemas.py       # Data models
    requirements.txt     # Python dependencies

 README.md                # This file

Pages & Components

Main Pages

  • Page - Drag-and-drop file upload with progress
  • ** Dashboard** - Animated metrics and document overview
  • Explorer - Interactive document navigation
  • Chat - AI assistant conversation interface
  • Download - Customizable report generation

Key Components

  • Library - Button, Card, Input, Progress, Badge, Accordion
  • States - Skeleton screens and spinners
  • Indicators - Color-coded risk level badges
  • Layout - Mobile-optimized grid system

API Endpoints

Document Management

  • POST /api/documents/upload - File upload processing
  • GET /api/documents/{id} - Document retrieval
  • DELETE /api/documents/{id} - Document deletion

Analysis Features

  • POST /api/analysis/extract-clauses - Clause extraction
  • POST /api/analysis/assess-risk - Risk assessment
  • POST /api/analysis/generate-summary - Document summary
  • POST /api/analysis/ask-question - Q&A functionality

Demo Ready Features

  • Upload - Smooth drag-and-drop with animations
  • Dashboard - Beautiful cards with hover effects
  • Explorer - Expandable accordion interface
  • UI - Typing indicators and message animations
  • Generation - Professional download interface
  • Design - Mobile-optimized layouts
  • States - Skeleton screens and progress indicators
  • Handling - User-friendly error messages
  • Deployment - Automatic deployment on push to main

** Live Demo**: https://harshad2321.github.io/Legal-AI-Simplifier

Known Issues & TODOs

Minor TypeScript Fixes Needed

  • Property name alignment in Document interface
  • formatFileSize utility function export
  • Alert severity property definition

Enhancement Opportunities

  • Add React Router for multi-page navigation
  • Implement real API integration
  • Add user authentication
  • Enhanced mobile responsiveness
  • Additional animation polish
  • Implement progressive web app (PWA) features

Team Members

Team Legal AI - Equal Contributors

Harshad Agrawal Parth Kosthi Krrish Talesara
Full-Stack Dev & AI Integration Full-Stack Dev & UI/UX Design Full-Stack Dev & Backend Architecture
harshad.agrawal2005@gmail.com parth.kosthi.btech2024@sitpune.edu.in krrish.talesara.btech2024@sitpune.edu.in
  • All team members contributed equally to this project - from ideation to deployment!*

Contact & Support

License

Built for hackathon - Open source for educational purposes.


Hackathon Ready!

This project demonstrates:

  • UI/UX that rivals top startups
  • architecture with TypeScript
  • integration for document processing
  • design for all devices
  • quality with proper structure
  • deployment for live demonstration

** Live Demo**: https://harshad2321.github.io/Legal-AI-Simplifier
**Ready to impress judges and win! **


Built with for the Google Cloud AI Hackathon by Team Legal AI
Contact: harshad.agrawal2005@gmail.com

Key Features

  • Upload: PDF, DOCX, TXT support with drag-and-drop
  • Analysis: Summary, clause extraction, risk assessment
  • Support: English, Hindi, Spanish, French summaries
  • Q&A: Ask questions about your documents
  • Alerts: Automated detection of risky clauses
  • Dashboard: Beautiful, intuitive interface

Architecture

        
   React Frontend   FastAPI Backend   Google Cloud   
   (TypeScript)          (Python)              Services     
        
                                                         
                             
   Tailwind                 FAISS                Vertex AI 
      CSS                 Vector DB             Cloud Store
                              Firestore 
                                                   

Quick Start

Prerequisites

  • Node.js 18+ and npm
  • Python 3.11+
  • Account with billing enabled
  • Docker (optional, for containerized deployment)

Clone the Repository

git clone https://github.com/Harshad2321/Legal-AI-Simplifier.git
cd Legal-AI-Simplifier

Backend Setup

cd backend

# Create virtual environment
python -m venv venv
source venv/bin/activate  # On Windows: venv\Scripts\activate

# Install dependencies
pip install -r requirements.txt

# Setup environment
cp .env.example .env
# Edit .env with your Google Cloud project settings

# Run backend
uvicorn app.main:app --reload --host 0.0.0.0 --port 8080

Frontend Setup

cd frontend

# Install dependencies
npm install

# Start development server
npm start

Google Cloud Setup

# Install Google Cloud CLI
# https://cloud.google.com/sdk/docs/install

# Authenticate
gcloud auth application-default login

# Set project
gcloud config set project YOUR_PROJECT_ID

# Enable APIs
gcloud services enable run.googleapis.com
gcloud services enable storage.googleapis.com
gcloud services enable firestore.googleapis.com
gcloud services enable aiplatform.googleapis.com
gcloud services enable translate.googleapis.com

# Create storage bucket
gsutil mb gs://legal-ai-documents-YOUR_PROJECT_ID

Development

Backend Structure

backend/
 app/
    main.py              # FastAPI application
    config.py            # Configuration management
    schemas.py           # Pydantic models
    routers/
       documents.py     # Document management
       analysis.py      # AI analysis endpoints
    services/
        gcp_client.py    # Google Cloud integration
        document_processor.py  # Text processing
        vector_store.py  # FAISS vector operations
 requirements.txt         # Python dependencies
 Dockerfile              # Container configuration
 deploy.sh               # Cloud Run deployment

Frontend Structure

frontend/
 src/
    components/          # Reusable UI components
    pages/              # Main application pages
    services/           # API integration
    types/              # TypeScript type definitions
    config/             # Configuration constants
    App.tsx             # Main application component
 package.json            # Node.js dependencies
 tailwind.config.js      # Tailwind CSS configuration

API Endpoints

Document Management

  • POST /api/v1/documents/upload - Upload document
  • GET /api/v1/documents/list - List documents
  • GET /api/v1/documents/{id} - Get document details
  • DELETE /api/v1/documents/{id} - Delete document
  • GET /api/v1/documents/{id}/status - Processing status

AI Analysis

  • POST /api/v1/analysis/{id}/summarize - Generate summary
  • POST /api/v1/analysis/{id}/clauses - Extract clauses
  • POST /api/v1/analysis/{id}/ask - Ask questions
  • POST /api/v1/analysis/{id}/alerts - Get risk alerts

Example Usage

// Upload document
const formData = new FormData();
formData.append('file', file);
const response = await fetch('/api/v1/documents/upload', {
  method: 'POST',
  body: formData
});

// Get summary
const summary = await fetch(`/api/v1/analysis/${documentId}/summarize`, {
  method: 'POST',
  headers: { 'Content-Type': 'application/json' },
  body: JSON.stringify({
    document_id: documentId,
    language: 'hi',  // Hindi summary
    max_length: 500
  })
});

Demo Script

For Hackathon Judges

  1. Upload Demo: Drag & drop a legal contract (PDF/DOCX)
  2. Real-time Processing: Show live status updates
  3. Multi-language Summary: Generate in English and Hindi
  4. Risk Analysis: Highlight critical clauses with color coding
  5. Interactive Q&A: Ask "What are my payment obligations?"
  6. Smart Alerts: Show automated risk warnings

Sample Questions for Demo

  • "What are the termination conditions?"
  • "What penalties might I face?"
  • "What are my financial obligations?"
  • "Are there any unusual clauses I should worry about?"

Production Deployment

Cloud Run (Recommended)

cd backend
chmod +x deploy.sh
./deploy.sh

Docker Compose (Local)

# Backend
cd backend
docker-compose up -d

# Frontend
cd frontend
npm run build
# Serve with your preferred static file server

Environment Variables

Backend (.env)

GOOGLE_CLOUD_PROJECT_ID=your-project-id
GOOGLE_CLOUD_STORAGE_BUCKET=legal-ai-documents
GOOGLE_APPLICATION_CREDENTIALS=path/to/service-account.json
DEBUG=False
LOG_LEVEL=INFO
FRONTEND_URL=https://your-frontend-domain.com

Frontend (.env)

REACT_APP_API_BASE_URL=https://your-backend-url.com
REACT_APP_DEMO_MODE=false

Testing

Backend Tests

cd backend
python test_api.py

Frontend Tests

cd frontend
npm test

Integration Tests

# Test complete flow
1. Upload document via frontend
2. Wait for processing
3. Test all analysis features
4. Verify API responses

Customization

Adding New Risk Patterns

Edit backend/app/services/document_processor.py:

self.risk_patterns = {
    "high": [
        r"penalty|penalties|fine|fines",
        r"your_new_pattern_here",
        # Add more patterns
    ]
}

Adding New Languages

  1. Update LANGUAGES in frontend/src/config/constants.ts
  2. Ensure Google Translate supports the language
  3. Test with sample documents

Styling Customization

Edit frontend/tailwind.config.js for theme changes:

module.exports = {
  theme: {
    extend: {
      colors: {
        primary: {
          // Your brand colors
        }
      }
    }
  }
}

Troubleshooting

Common Issues

Backend won't start

# Check Python version
python --version  # Should be 3.11+

# Check dependencies
pip install -r requirements.txt

# Check Google Cloud authentication
gcloud auth application-default login

Frontend build fails

# Clear node_modules and reinstall
rm -rf node_modules package-lock.json
npm install

# Check Node.js version
node --version  # Should be 18+

API connection issues

  1. Verify backend is running on port 8080
  2. Check CORS settings in backend/app/main.py
  3. Ensure frontend proxy is configured

Google Cloud errors

  1. Verify project ID in environment variables
  2. Check API enablement: gcloud services list --enabled
  3. Verify service account permissions

Performance Optimization

Backend

  • processing: Document analysis runs in background
  • caching: FAISS index persisted to disk
  • pooling: Reuse GCP client connections
  • management: Chunked processing for large documents

Frontend

  • splitting: React.lazy() for route-based splitting
  • optimization: WebP format with fallbacks
  • Caching: Service worker for offline functionality
  • analysis: webpack-bundle-analyzer for optimization

Security

Backend Security

  • validation: Pydantic schemas for all endpoints
  • validation: MIME type checking
  • limits: 10MB max file size
  • handling: No sensitive information in error messages

Frontend Security

  • protection: React's built-in sanitization
  • protection: CORS configuration
  • variables: No secrets in client-side code

Monitoring

Health Checks

  • Backend: GET /health
  • Service status monitoring
  • Error rate tracking
  • Performance metrics

Logging

# Backend logs
tail -f logs/app.log

# Frontend console
console.log('User action:', action);

Contributing

Development Workflow

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

Code Standards

  • Backend: Black formatting, type hints, docstrings
  • Frontend: ESLint, Prettier, TypeScript strict mode
  • Tests: Minimum 80% coverage
  • Documentation: Update README for new features

Hackathon Submission Checklist

Completed Requirements

  • Functional Prototype - Working demo with full AI capabilities
  • Google Cloud Integration - Backend deployed on Cloud Run with AI services
  • Live Demo - https://harshad2321.github.io/Legal-AI-Simplifier
  • Source Code - Public GitHub repository with clean, documented code
  • Comprehensive Documentation - Detailed README with setup instructions
  • Real-world Impact - Addresses genuine legal accessibility challenges
  • Scalable Architecture - Enterprise-ready design patterns

Technical Implementation

  • Frontend: React 18 + TypeScript + TailwindCSS
  • Backend: Python FastAPI + Google Cloud AI
  • Database: Cloud Firestore for document storage
  • Services: Gemini API + Vertex AI for document processing
  • Deployment: Cloud Run (Backend) + GitHub Pages (Frontend)

Demo Video

3-Minute Demo Video: [Coming Soon]

  • Live demonstration of document upload and analysis
  • AI-powered clause extraction and risk assessment
  • Interactive Q&A with legal documents
  • Report generation and download functionality

License

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

Acknowledgments

  • Cloud for AI and infrastructure services
  • Hackathon for the platform and opportunity
  • React and FastAPI communities for excellent frameworks
  • shadcn/ui for beautiful component library

Team Legal AI - GenAI Exchange Hackathon 2025

Built for: GenAI Exchange Hackathon
Team Members: Harshad Agrawal, Parth Kosthi, Krrish Talesara
Contact: harshad.agrawal2005@gmail.com
Repository: https://github.com/Harshad2321/Legal-AI-Simplifier

Disclaimer: This is AI assistance, not legal advice. Always consult with qualified legal professionals for important legal matters.

About

An AI-powered platform that transforms complex legal documents into clear, actionable insights using Google Cloud AI technologies.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published