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



