π AI-Powered Legal Document Analysis Platform
Transforming complex legal documents into plain English insights using cutting-edge Generative AI
The Legal AI Platform revolutionizes legal document analysis by leveraging Google Cloud's advanced AI services to make complex legal documents accessible to everyone. Built for the SPARK182 hackathon, this solution transforms legal jargon into actionable insights through intelligent AI processing.
- Legal documents are complex and intimidating for non-legal professionals
- Traditional legal consultation is expensive (avg. $300-500/hour)
- Document review is time-consuming and prone to human error
- Small businesses and individuals lack access to affordable legal analysis
AI-powered platform that democratizes legal document understanding through:
- Instant Analysis: Upload β AI Processing β Plain English Insights
- Smart Search: RAG-powered document querying with contextual answers
- Risk Assessment: Automated compliance and risk factor identification
- Cost Effective: 95% cost reduction compared to traditional legal consultation
|
|
|
|
graph TB
A[Client React App] --> B[Express.js API]
B --> C[Google Cloud Document AI]
B --> D[Vertex AI - Generative Models]
B --> E[Google Cloud Storage]
B --> F[Vector Store]
C --> G[Text Extraction]
D --> H[Legal Analysis]
D --> I[Embeddings Generation]
F --> J[Semantic Search]
subgraph "AI Pipeline"
G --> H
H --> I
I --> J
end
subgraph "Cloud Infrastructure"
C
D
E
end
Frontend
React 18 # Modern UI framework
Tailwind CSS # Utility-first styling
Recharts # Data visualization
Lucide React # Icon library
Context API # State management
WebSocket # Real-time updatesBackend
Node.js # Runtime environment
Express.js # Web framework
Multer # File upload handling
Google Cloud AI # AI/ML services
WebSocket Server # Real-time communication
CORS # Cross-origin securityAI/ML Services
Document AI # Text extraction
Vertex AI # Generative models
βββ text-bison@002 # Legal analysis
βββ text-embedding-004 # Vector embeddings
RAG Architecture # Semantic search
Vector Store # In-memory similarity- Node.js 18+ and npm
- Google Cloud Project with billing enabled
- Document AI and Vertex AI APIs activated
git clone https://github.com/bhargav-abhay/legal-document.git
cd legal-document# Backend dependencies
npm install
# Frontend dependencies
cd frontend
npm install
cd ..Create .env file in root directory:
# Google Cloud Configuration
GOOGLE_CLOUD_PROJECT=your-project-id
GOOGLE_APPLICATION_CREDENTIALS=path/to/service-account.json
VERTEX_AI_LOCATION=us-central1
DOCUMENT_AI_LOCATION=us
DOCUMENT_AI_PROCESSOR_ID=your-processor-id
STORAGE_BUCKET_NAME=your-bucket-name
# API Configuration
PORT=8000
FRONTEND_URL=http://localhost:3000
# Optional: Google Search API for legal news
GOOGLE_SEARCH_API_KEY=your-api-key
GOOGLE_SEARCH_ENGINE_ID=your-engine-id# Install Google Cloud CLI
curl https://sdk.cloud.google.com | bash
exec -l $SHELL
# Authenticate
gcloud auth login
gcloud config set project YOUR_PROJECT_ID
# Enable required APIs
gcloud services enable documentai.googleapis.com
gcloud services enable aiplatform.googleapis.com
gcloud services enable storage.googleapis.com
# Create service account
gcloud iam service-accounts create legal-ai-service
gcloud projects add-iam-policy-binding YOUR_PROJECT_ID \
--member="serviceAccount:legal-ai-service@YOUR_PROJECT_ID.iam.gserviceaccount.com" \
--role="roles/documentai.apiUser"
gcloud projects add-iam-policy-binding YOUR_PROJECT_ID \
--member="serviceAccount:legal-ai-service@YOUR_PROJECT_ID.iam.gserviceaccount.com" \
--role="roles/aiplatform.user"
# Download service account key
gcloud iam service-accounts keys create ./service-account.json \
--iam-account=legal-ai-service@YOUR_PROJECT_ID.iam.gserviceaccount.com# Terminal 1: Start backend server
npm start
# Terminal 2: Start React development server
cd frontend
npm startVisit http://localhost:3000 to access the application.
POST /api/analyze-document
Content-Type: multipart/form-data
# Request
- file: Document file (PDF, DOC, DOCX, TXT, RTF)
- userI