LegalEase AI is a comprehensive platform that transforms complex legal documents into plain English using Google's cutting-edge Gemini AI. The platform features document analysis, real-time meeting transcription, interactive AI chat, and voice-enabled features to make legal information accessible to everyone.
- π Document Analysis: Upload contracts, agreements, or legal documents for AI-powered analysis
- ποΈ Real-time Meeting Transcription: Chrome extension for Google Meet with live legal analysis
- π¬ Interactive AI Chat: Ask questions about your documents with context-aware responses
- π§ RAG-Powered Search: Retrieval-Augmented Generation for intelligent document querying
- π Vector Search: Advanced semantic search using embeddings for precise legal clause matching
- π£οΈ Voice Features: Speech-to-text input and text-to-speech output
- βοΈ Legal Risk Assessment: Automatic identification of high, medium, and low-risk clauses
- π Multi-language Support: Multiple language options for global accessibility
- π Smart Embeddings: Document vectorization for similarity search and contextual understanding
- Frontend: Next.js 15.2.4 with App Router & TypeScript
- AI Engine: Google Gemini 2.0 Flash (via
@google/genaiSDK) - Vector Database: Google Vertex AI Vector Search for enterprise-grade similarity search
- Embeddings Model: Google Universal Sentence Encoder & text-embedding-004
- RAG Architecture: Retrieval-Augmented Generation for context-aware responses
- Authentication: NextAuth.js with Google OAuth
- Database: Firebase Firestore with Vertex AI vector index integration
- Real-time Communication: WebSocket with Socket.IO
- Chrome Extension: Manifest v3 for Google Meet integration
- Voice Processing: Google Speech-to-Text & Text-to-Speech APIs
- Search Engine: Hybrid search combining Vertex AI vector similarity and traditional indexing
google-hackathon/
βββ π app/ # Next.js app router pages
β βββ π api/ # API routes
β β βββ π analyze/ # Document analysis endpoint
β β βββ π chat/ # AI chat functionality
β β βββ π speech-to-text/ # Voice recognition
β β βββ π text-to-speech/ # Voice synthesis
β β βββ π transcribe/ # Meeting transcription
β β βββ π websocket/ # Real-time connections
β βββ π upload/ # Document upload interface
β βββ π dashboard/ # Main dashboard
β βββ π meet/ # Google Meet integration
β βββ π chat/ # Chat interface
β βββ π voice-test/ # Voice features testing
β βββ π settings/ # User settings
βββ π chrome-extension/ # Chrome extension for Meet
β βββ π manifest.json # Extension configuration
β βββ π background.js # Background script
β βββ π content.js # Content script for Meet
β βββ π popup.html/js # Extension popup
β βββ π build/ # Built extension files
βββ π lib/ # Utility libraries
β βββ π document-processor.ts # Gemini AI document processing
β βββ π gemini.ts # AI client configuration
β βββ π firebase.ts # Firebase configuration
β βββ π vertex-vector-store.ts # Vertex AI Vector Search operations
β βββ π embeddings.ts # Text embedding generation and processing
β βββ π rag-engine.ts # RAG implementation for contextual retrieval
β βββ π search-engine.ts # Hybrid search functionality
β βββ π languages.ts # Language support
β βββ π websocket.ts # WebSocket utilities
βββ π components/ # React components
β βββ π chat-interface.tsx # AI chat component
β βββ π transcript-analyzer.tsx # Meeting analysis
β βββ π document-viewer.tsx # Document display
β βββ π ui/ # UI components
βββ π hooks/ # React hooks
β βββ π use-voice-recording.ts # Voice input hook
β βββ π use-text-to-speech.ts # Voice output hook
βββ π docs/ # Documentation
βββ π websocket-integration.md # WebSocket setup
βββ π voice-chat-features.md # Voice features
βββ π google-cloud-transcription.md
- Node.js 18+ and pnpm
- Google Cloud API Key (Gemini AI & Embeddings)
- Google Cloud Project with Vertex AI enabled
- Firebase Project
- Chrome Browser (for extension)
git clone <repository-url>
cd google-hackathon
pnpm installCreate a .env file with the following configuration:
# π€ Gemini AI Configuration
NEXT_PUBLIC_GEMINI_API_KEY=your_gemini_api_key
# π§ Google Cloud Vertex AI & Embeddings
GOOGLE_CLOUD_PROJECT_ID=your_gcp_project_id
GOOGLE_CLOUD_LOCATION=us-central1
VERTEX_AI_INDEX_ENDPOINT=your_vertex_ai_index_endpoint
VERTEX_AI_INDEX_ID=your_vertex_ai_index_id
GOOGLE_EMBEDDINGS_API_KEY=your_google_embeddings_key
GOOGLE_APPLICATION_CREDENTIALS=path/to/service-account.json
# π₯ Firebase Configuration
NEXT_PUBLIC_FIREBASE_API_KEY=your_firebase_api_key
NEXT_PUBLIC_FIREBASE_AUTH_DOMAIN=your_project.firebaseapp.com
NEXT_PUBLIC_FIREBASE_PROJECT_ID=your_project_id
NEXT_PUBLIC_FIREBASE_STORAGE_BUCKET=your_project.firebasestorage.app
NEXT_PUBLIC_FIREBASE_MESSAGING_SENDER_ID=your_sender_id
NEXT_PUBLIC_FIREBASE_APP_ID=your_app_id
# π Google OAuth
NEXT_PUBLIC_GOOGLE_CLIENT_ID=your_google_client_id
NEXT_PUBLIC_GOOGLE_CLIENT_SECRET=your_google_client_secret
# π NextAuth Configuration
NEXTAUTH_SECRET=your_nextauth_secret
NEXTAUTH_URL=http://localhost:3000
# π£οΈ Voice Services
GOOGLE_SPEECH_TO_TEXT=your_gemini_api_key
GOOGLE_TEXT_TO_SPEECH_KEY=your_gemini_api_key# Start the development server
pnpm dev
# Build for production
pnpm build
# Start production server
pnpm startVisit http://localhost:3000 to see the application.
- Navigate to Extensions:
chrome://extensions/ - Enable Developer Mode: Toggle in top-right corner
- Load Extension: Click "Load unpacked" β select
chrome-extensiondirectory - Verify Installation: Extension appears in your extensions list
- Join a Google Meet: Start or join any meeting
- Activate Extension: Click the LegalEase icon in your browser toolbar
- Connect to Server: Click "Connect to Server" in the popup
- Start Transcription: Click "Start Transcription" when ready
- View Analysis: Real-time transcript and AI analysis appear on your dashboard
- Direct AI Processing: Upload PDFs, images, or documents directly to Gemini AI
- Vector Embeddings: Automatic document vectorization using Google's text-embedding-004
- Smart Text Extraction: Superior accuracy compared to traditional OCR
- Semantic Search: Find similar clauses across your document library using Vertex AI vector similarity
- Legal Risk Assessment: Automatic identification of risky clauses with severity levels
- Plain English Translation: Complex legal jargon simplified for easy understanding
- Interactive Q&A: Context-aware chat about specific document content with RAG enhancement
- Multi-format Support: PDFs, Word docs, images, and text files
- Knowledge Base: Build a searchable Vertex AI vector database of your legal documents
- Google Meet Integration: Seamless Chrome extension integration
- Live Audio Capture: Real-time audio processing during meetings
- WebSocket Communication: Instant data streaming to your dashboard
- Legal Analysis: AI identifies legal topics and risks in conversations
- Privacy-First: Audio processed securely, no local storage
- RAG-Enhanced Responses: Retrieval-Augmented Generation for accurate, context-aware answers
- Vector Search Integration: Chat queries automatically search your document embeddings
- Context-Aware: AI remembers your uploaded documents and their semantic content
- Legal Expertise: Specialized prompts for legal document analysis with knowledge retrieval
- Voice Support:
- Speech-to-Text: Speak your questions naturally
- Text-to-Speech: Listen to AI responses
- History Management: Save and retrieve past conversations with semantic indexing
- Multi-language: Support for multiple languages with cross-lingual embeddings
- Smart Suggestions: AI suggests relevant follow-up questions based on document content
- High-Quality Recognition: Google Speech-to-Text API
- Natural Voice Output: Google Text-to-Speech with natural voices
- Smart Processing: Optimized for legal terminology
- Error Handling: Comprehensive fallback mechanisms
- Browser Compatibility: Works across modern browsers
| Endpoint | Method | Description |
|---|---|---|
/api/analyze |
POST | Analyze uploaded documents with Gemini AI |
/api/chat |
POST | Interactive AI chat with RAG enhancement |
/api/embeddings |
POST | Generate document embeddings for vector storage |
/api/vector-search |
POST | Semantic search across document library |
/api/rag-query |
POST | RAG-powered document querying |
/api/speech-to-text |
POST | Convert voice recordings to text |
/api/text-to-speech |
POST | Convert text responses to speech |
/api/transcribe |
POST | Process meeting transcripts from extension |
/api/websocket |
WebSocket | Real-time communication for live features |
/api/latest-transcript |
GET | Retrieve latest meeting transcript |
/api/chat-history |
GET/POST | Manage chat conversation history |
/api/document-similarity |
POST | Find similar documents using vector search |
# Verify Gemini AI connectivity
node test-new-gemini.js
# Expected output: "Yes, the new Gemini SDK is working!"- β Document Upload: Test various file types (PDF, DOC, images)
- β Vector Embedding: Verify documents are properly vectorized and stored
- β Semantic Search: Test vector-based document similarity search
- β RAG Functionality: Verify contextual retrieval in chat responses
- β Chat Features: Try document-specific questions with RAG enhancement
- β Voice Input: Test microphone recording and transcription
- β Voice Output: Test text-to-speech playbook
- β Meet Integration: Join Google Meet with extension enabled
- β Real-time Sync: Verify WebSocket communication
- β Embedding Quality: Test cross-document legal clause matching
Visit /voice-test to test speech-to-text and text-to-speech functionality.
The application is ready for deployment to:
Your successful build shows:
- β All routes compiled successfully
- β Static pages pre-rendered (30/30)
- β Bundle sizes optimized (~169-221 KB first load)
- β No critical compilation errors
Ensure all environment variables from .env are configured in your deployment platform.
- Model:
gemini-2.0-flash-exp(latest experimental model) - Direct File Upload: Superior to traditional OCR approaches
- Context Management: Maintains document context across conversations
- Auto-cleanup: Files automatically deleted after processing for privacy
- Vector Store: Google Vertex AI Vector Search for enterprise-grade similarity search
- Embedding Model: Google Universal Sentence Encoder (text-embedding-004)
- RAG Implementation: Retrieval-Augmented Generation for enhanced responses
- Hybrid Search: Combines Vertex AI semantic vector search with traditional keyword matching
- Document Chunking: Smart text segmentation for optimal embedding quality
- Similarity Threshold: Configurable relevance scoring for precise retrieval
- Auto-scaling: Vertex AI handles scaling and performance optimization automatically
- Manifest v3: Latest Chrome extension standard
- Content Script: Integrates seamlessly with Google Meet UI
- Background Script: Manages WebSocket connections and audio capture
- Popup Interface: User-friendly control panel
- Google OAuth: Secure user authentication
- Firebase Integration: User data and chat history storage
- API Key Protection: Secure environment variable handling
- CORS Configuration: Proper cross-origin request handling
// lib/gemini.ts
const genAI = new GoogleGenAI({
apiKey: process.env.NEXT_PUBLIC_GEMINI_API_KEY,
});
// Using the latest experimental model
model: "gemini-2.0-flash-exp";// lib/vertex-vector-store.ts
import { VertexAI } from "@google-cloud/vertexai";
import { MatchServiceClient } from "@google-cloud/aiplatform";
const vertex = new VertexAI({
project: process.env.GOOGLE_CLOUD_PROJECT_ID,
location: process.env.GOOGLE_CLOUD_LOCATION,
});
const matchClient = new MatchServiceClient();
// Document embedding and storage
const embedDocument = async (text: string, metadata: any) => {
const embedding = await generateEmbedding(text);
// Store in Vertex AI Vector Search
await matchClient.upsertDatapoints({
index: `projects/${process.env.GOOGLE_CLOUD_PROJECT_ID}/locations/${process.env.GOOGLE_CLOUD_LOCATION}/indexes/${process.env.VERTEX_AI_INDEX_ID}`,
datapoints: [
{
datapointId: metadata.docId,
featureVector: embedding,
restricts: [
{ namespace: "userId", allowList: [metadata.userId] },
{ namespace: "docType", allowList: [metadata.docType] },
],
},
],
});
};// lib/rag-engine.ts
export const ragQuery = async (question: string, userId: string) => {
// 1. Generate query embedding
const queryEmbedding = await generateEmbedding(question);
// 2. Vertex AI Vector similarity search
const searchResponse = await matchClient.findNeighbors({
indexEndpoint: process.env.VERTEX_AI_INDEX_ENDPOINT,
queries: [
{
datapoint: {
featureVector: queryEmbedding,
},
neighborCount: 5,
restricts: [{ namespace: "userId", allowList: [userId] }],
},
],
});
// 3. Construct context from retrieved documents
const context = searchResponse[0].nearestNeighbors
.map((neighbor) => neighbor.datapoint.metadata.text)
.join("\n\n");
// 4. Generate response with context
return await generateContextualResponse(question, context);
};// Real-time meeting transcription
const socket = io(SERVER_URL, {
transports: ["websocket", "polling"],
upgrade: true,
});// Configurable voice settings
{
voice: "en-IN-Standard-A",
languageCode: "en-IN",
speed: 1.0
}π€ Microphone Not Working
- Check browser permissions for microphone access
- Ensure microphone isn't being used by other applications
- Try refreshing the page
π Extension Not Connecting
- Verify the Next.js server is running on
localhost:3000 - Check Chrome extension permissions
- Try reloading the extension
π Document Upload Failing
- Ensure file size is under 10MB
- Check supported file formats (PDF, DOC, images)
- Verify Gemini API key is configured correctly
π Vector Search Not Working
- Check Google Cloud project ID and Vertex AI API enablement
- Verify Vertex AI Vector Search index exists and is deployed
- Ensure service account has proper Vertex AI permissions
- Check index endpoint configuration
π§ RAG Responses Inaccurate
- Verify Vertex AI embedding model configuration
- Check similarity threshold settings in Vector Search
- Ensure document chunking is optimized for legal content
- Review index deployment status and health
π Voice Features Not Working
- Check browser audio permissions
- Ensure speakers/headphones are working
- Verify Google API keys are set correctly
Additional documentation available in the docs directory:
- WebSocket Integration: Real-time communication setup
- Voice Features: Speech recognition and synthesis
- Google Cloud Transcription: Meeting transcription setup
- Integration Guide: Gemini AI integration details
- Vector Database Setup: Vertex AI Vector Search configuration and embedding strategies
- RAG Implementation: Retrieval-Augmented Generation with Vertex AI architecture
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
Important Notice: This application provides information and analysis for educational purposes only and does not constitute legal advice. Always consult with qualified legal professionals for important legal matters. The AI-generated content should be verified independently.
This project is part of a Google Hackathon submission and follows applicable hackathon guidelines.
- Build Time: ~2-3 seconds
- Bundle Size: 101-221 KB (optimized)
- API Routes: 20+ endpoints
- Vector Dimensions: 768 (text-embedding-004)
- Max Document Size: 10MB per upload
- Embedding Speed: ~500ms per document chunk
- RAG Retrieval: Top-5 similar documents
- Chrome Extension: Manifest v3 compliant
- AI Model: Google Gemini 2.0 Flash (Experimental)
- Languages Supported: 10+ languages
- File Formats: PDF, DOC, images, text
π Built with β€οΈ for the Google Hackathon
Making legal documents accessible to everyone through the power of AI
Live Demo β’ Chrome Extension β’ API Docs
# Install dependencies
pnpm install
# Start development server
pnpm dev
# Build for production
pnpm build
# Test Gemini integration
node test-new-gemini.js
# Package Chrome extension
cd chrome-extension && ./package-extension.shReady to deploy! π― Your LegalEase AI platform is now ready for production deployment.


