π Quick Start β’ π Deployment β’ π Features β’ ποΈ Architecture β’ π Docs β’ π» Demo
LegalMind is a cutting-edge, Google Cloud-native platform that revolutionizes legal contract analysis and research. Powered by Google's Gemini 2.0 Flash AI model, it orchestrates 6 specialized legal agents with 14+ intelligent tools to provide comprehensive contract intelligence, compliance verification, risk assessment, and automated legal documentation.
Perfect for legal teams, compliance officers, contract managers, and enterprises seeking AI-powered legal analysis at scale.
|
|
+--------------------+ +-----------------------------+
| User | | Next.js Dashboard |
| (Uploads Legal |<------>| (Review & Interactions) |
| PDF) | +--------------^-------------+
+---------+----------+ |
| |
v |
+---------------------------+ |
| Upload & Ingestion | |
| (FastAPI / Cloud Run) | |
+-------------+-------------+ |
| |
v |
+--------------------+ |
| Router / Query | |
| Classifier |-----------------+
+----+-------+-------+
| |
+-------+ +-----------------------------+
| | |
v v v
+----------+ +-------------+ +-------------+
| Risk | | Compliance | | Summary |
| Agent | | Agent | | Agent |
+----+----+ +------+------ +--+-----+------+
| | |
+-----------+--------------+---------------+
v
+----------------------------+
| Firestore Memory |
| (Insights, Flags, Notes) |
+--------------+-------------+
|
v
+------------------------+
| Aggregation / API |
| (FastAPI Backend) |
+------------------------+
| π¨ Layer | β‘ Technology | π Purpose |
|---|---|---|
| π₯οΈ Frontend | Next.js 15 β’ React 18 β’ TypeScript β’ Tailwind CSS | Modern UI with real-time updates |
| βοΈ Backend | FastAPI β’ Python 3.11 β’ Uvicorn | High-performance async API |
| π€ AI/ML | Google Gemini 2.0 Flash | Advanced reasoning & function calling |
| πΎ Database | Google Cloud Firestore | Scalable document database (99.999% SLA) |
| π¦ Storage | Google Cloud Storage | Secure PDF & document management |
| βοΈ Infrastructure | Google Cloud Platform | Serverless, auto-scaling deployment |
| π― Component | π Count | π Details |
|---|---|---|
| π€ Legal Agents | 6 | Specialized AI agents for different legal tasks |
| π οΈ Tools | 14+ | Contract, compliance, risk, document, clause tools |
| π API Endpoints | 31 | 29 REST + 2 WebSocket for real-time communication |
| πΎ Collections | 6 | Sessions, messages, contracts, clauses, logs, docs |
| π» Lines of Code | 9,000+ | ~6,000 backend + ~3,000 frontend |
| β Test Coverage | 97% | 34/35 tests passing |
| β Python 3.11+ | β Node.js 18+ | β Google Gemini API Key | β Google Cloud Project with Firestore |
git clone https://github.com/smirk-dev/gemini-hackathon.git
cd gemini-hackathon# Create backend/.env.local with your secrets
GEMINI_API_KEY=your_api_key_here
GOOGLE_CLOUD_PROJECT=legalmind-486106
APP_ENV=development
DEBUG=trueπͺ Option A: Automated (Windows)
start-legalmind.batπ Option B: Manual (All Platforms)
# Terminal 1: Backend
cd backend
python main_new.py
# Terminal 2: Frontend
cd frontend
npm install
npm run dev| π― Service | π URL | π Description |
|---|---|---|
| π Web App | http://localhost:3000 | Main application interface |
| βοΈ API | http://localhost:8000 | Backend API server |
| π API Docs | http://localhost:8000/docs | Interactive Swagger UI |
# 1οΈβ£ Run setup script to configure GCP
./setup-gcp.ps1 # Windows
# or
./setup-gcp.sh # macOS/Linux
# 2οΈβ£ Add GitHub secrets (from script output)
# - GCP_PROJECT_ID
# - WIF_PROVIDER
# - WIF_SERVICE_ACCOUNT
# - FIREBASE_SERVICE_ACCOUNT
# 3οΈβ£ Push to main branch
git push origin main
# β¨ GitHub Actions automatically deploys:
# - Backend β Cloud Run
# - Frontend β Firebase Hosting| π Frontend | Firebase Hosting (Global CDN + Auto-scaling) |
| βοΈ Backend | Google Cloud Run (Serverless, Auto-scaling) |
| πΎ Database | Firestore (99.999% SLA, Global Replication) |
| π¦ Storage | Cloud Storage (PDFs & Documents) |
| βοΈ Cloud Run | ~$0.40 per million requests |
| π Firebase Hosting | Free tier (10 GB/month) |
| πΎ Firestore | Free tier (25k reads + writes/day) |
| π΅ Total | $5-15/month for moderate usage |
π Full Deployment Guides:
- Quick Deploy Guide - 5-minute setup
- Complete Deployment Guide - Advanced configuration
|
|
|
|
POST /api/chat # Send message to legal agents
GET /api/chat/sessions # List all chat sessions
POST /api/chat/session # Create new session
WS /ws/chat/{session_id} # Real-time WebSocket chatPOST /api/contracts/upload # Upload contract PDF
GET /api/contracts # List all contracts
GET /api/contracts/{id} # Get contract details
GET /api/contracts/{id}/clauses # Extract clauses
GET /api/contracts/{id}/download # Download contractGET /api/compliance/frameworks # List compliance frameworks
GET /api/compliance/check/{id} # Check compliance status
GET /api/risk/assess/{id} # Assess contract risksGET /api/health # System health check
GET /api/agents # List all agents
GET /api/agents/{id} # Get agent detailsπ Full Documentation: Visit http://localhost:8000/docs for interactive Swagger UI
cd backend
python test_backend.pyπ Expected Results: 34/35 tests passing (97% coverage)
# Quick health verification
curl http://localhost:8000/api/health
# Expected response:
# {"status": "healthy", "version": "1.0.0"}gemini-hackathon/
βββ π backend/ # FastAPI Server
β βββ services/ # Google Cloud integrations
β β βββ gemini_service.py # Gemini API wrapper
β β βββ firestore_service.py # Database service
β β βββ storage_service.py # Cloud Storage service
β βββ agents/ # Legal AI agents
β β βββ agent_definitions_new.py # 6 specialized agents
β β βββ agent_strategies_new.py # Query routing logic
β βββ tools/ # 14+ legal tools
β β βββ contract_tools.py # Contract analysis
β β βββ compliance_tools.py # Compliance checking
β β βββ risk_tools.py # Risk assessment
β β βββ clause_tools.py # Clause extraction
β β βββ document_tools.py # Document generation
β β βββ logging_tools.py # Thinking logs
β βββ api/ # REST API
β β βββ endpoints_new.py # 31 endpoints
β β βββ app_new.py # FastAPI setup
β βββ managers/ # Business logic
β β βββ chatbot_manager_new.py # Session orchestration
β βββ config/ # Configuration
β β βββ settings.py # Environment settings
β βββ main_new.py # Entry point
β βββ .env.local # Secrets (gitignored)
β βββ .env.example # Config template
β βββ firestore.rules # Security rules
β
βββ π frontend/ # Next.js Application
β βββ app/
β β βββ page.tsx # Landing page
β β βββ chat/ # Chat interface
β β βββ contracts/ # Contract management
β β βββ dashboard/ # Analytics dashboard
β β βββ reports/ # Documents & reports
β β βββ thinking-logs/ # Agent reasoning
β β βββ api/ # API proxy routes
β βββ components/ # Reusable UI components
β βββ lib/ # Utilities & helpers
β βββ app/globals.css # Theme (legal blue)
β
βββ π docs/ # Documentation
β βββ PROJECT_STATUS.md
β βββ IMPLEMENTATION_PLAN.md
β βββ FRONTEND_CHANGES.md
β βββ CODE_TRANSFORMATION_GUIDE.md
β
βββ π start-legalmind.bat # Quick start script
βββ π .env.local # Your secrets
βββ π README.md # This file
βββ β‘ QUICK_START.md # Quick reference
βββ β
COMPLETE_SETUP.md # Full guide
βββ ποΈ FIRESTORE_SETUP.md # Database setup
βββ π STATUS.txt # System overview
βββ π LICENSE.md # Apache-2.0
|
|
π See COMPLETE_SETUP.md for detailed production deployment.
| π― Metric | β‘ Value | π Status |
|---|---|---|
| Backend Startup | < 3 seconds | π’ Optimal |
| Frontend Build | 12.7 seconds | π’ Fast |
| API Response Time | < 100ms (local) | π’ Excellent |
| Chat Response Time | 2-5 seconds | π’ Quick |
| Test Coverage | 97% | π’ High |
| Firestore SLA | 99.999% | π’ Enterprise |
# 1οΈβ£ Fork the repository
git clone https://github.com/your-username/gemini-hackathon.git
# 2οΈβ£ Create feature branch
git checkout -b feature/amazing-feature
# 3οΈβ£ Commit your changes
git commit -m 'Add amazing feature'
# 4οΈβ£ Push to branch
git push origin feature/amazing-feature
# 5οΈβ£ Open Pull Requestπ‘ Ideas for Contributions:
- π Bug fixes and improvements
- β¨ New legal tools or agents
- π Documentation enhancements
- π§ͺ Additional test coverage
- π Internationalization support
|
|
π Read COMPLETE_SETUP.md for detailed guide
π¬ Check STATUS.txt for system overview
π Review docs/ directory for technical details
This project is licensed under the Apache License 2.0 - see LICENSE.md for details.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
Free to use for commercial and non-commercial purposes β
| Technology | Purpose |
|---|---|
| βοΈ Google Cloud Platform | Enterprise-grade cloud infrastructure |
| π€ Google Gemini 2.0 Flash | Advanced AI capabilities & reasoning |
| β‘ FastAPI | High-performance backend framework |
| βοΈ Next.js | Modern React-based frontend |
| πΎ Firestore | Scalable NoSQL database |
| π Open Source Community | Amazing tools & libraries |
Special thanks to all contributors and the legal tech community!
Start with QUICK_START.md for a guided walkthrough
start-legalmind.batGoogle Cloud Platform β’ Gemini 2.0 Flash AI β’ FastAPI β’ Next.js β’ Firestore
βοΈ Empowering legal teams with enterprise-grade AI intelligence
Made with β€οΈ for the modern legal world


