Your LegalMind legal contract analysis platform is now fully configured and running!
| Service | URL | Status |
|---|---|---|
| Frontend (Web App) | http://localhost:3000 | ✅ Running |
| Backend API | http://localhost:8000 | ✅ Running |
| API Documentation | http://localhost:8000/docs | ✅ Available |
| Google Firestore | legalmind-486106 | ✅ Connected |
- Frontend: Next.js 15 + React 18 + TypeScript + Tailwind CSS
- Backend: FastAPI + Python 3.11
- AI Model: Google Gemini 2.0 Flash with function calling
- Database: Google Cloud Firestore (Native mode)
- Storage: Google Cloud Storage
- Theme: Professional legal blue (
oklch(0.45 0.16 250))
- 6 specialized legal agents (contract parsing, compliance checking, risk assessment, etc.)
- 14+ legal analysis tools (clause extraction, compliance checking, risk scoring, etc.)
- Real-time chat with WebSocket support
- Session management with Firestore
- PDF contract upload and processing
- Thinking logs for agent reasoning transparency
- Interactive chat interface with file upload
- Contract management (upload, list, detail, download)
- Dashboard with country risk heatmap
- Compliance checking interface
- Risk assessment viewer
- Document generation and export
Location: backend/.env.local
Contains:
GEMINI_API_KEY- Your Google Generative AI API keyGOOGLE_CLOUD_PROJECT- Project ID:legalmind-486106- Application settings (debug mode, environment, etc.)
Security Note: This file is in .gitignore and is never committed to version control.
Location: backend/firestore.rules
Current rules allow all reads/writes for development. For production, use the commented-out rules that require authentication.
cd backend
python main_new.py- Reads credentials from
backend/.env.local - Automatically loads
.envas fallback - Connects to Firestore project:
legalmind-486106
cd frontend
npm run dev- Available at http://localhost:3000
- Proxies API calls to backend at http://localhost:8000
Open two terminals and run both commands simultaneously.
Interactive API docs available at: http://localhost:8000/docs
Chat
GET /api/chat/sessions- List all chat sessionsPOST /api/chat/session- Create new sessionPOST /api/chat- Send message to agentsWebSocket /ws/chat/{session_id}- Real-time chat
Contracts
POST /api/contracts/upload- Upload contract PDFGET /api/contracts- List contractsGET /api/contracts/{id}- Get contract detailsGET /api/contracts/{id}/clauses- Extract clausesGET /api/contracts/{id}/download- Download contract
Compliance
GET /api/compliance/frameworks- Available frameworksGET /api/compliance/check/{contract_id}- Check compliance
Risk Assessment
GET /api/risk/assess/{contract_id}- Assess contract risks
Agents
GET /api/agents- List available agentsGET /api/agents/{id}- Get agent details
- Project Name: LegalMind
- Project ID: legalmind-486106
- Project Number: 677928716377
- Firestore Database: (default)
- Edition: Standard Edition
- Mode: Firestore Native
- Location: Multi-region (nam5 - United States)
- Availability SLA: 99.999%
Automatically created and managed:
sessions- Chat session storagemessages- Message historycontracts- Uploaded contract documentsclauses- Extracted contract clausesthinking_logs- Agent reasoning processdocuments- Generated legal documents
✅ Deployed: Allow all reads/writes for development
- Visit http://localhost:3000
- You should see the LegalMind landing page with "LM" logo (blue badge)
- Navigation includes: Chat, Contracts, Dashboard, Reports, Thinking Logs
- Visit http://localhost:8000/docs
- Try the
GET /api/healthendpoint - Try
GET /api/chat/sessionsto list sessions
- Go to http://localhost:3000/chat
- Type a message like "What compliance frameworks should I check for?"
- Backend will route to appropriate agent and return response
- Go to http://localhost:3000/contracts
- Upload a PDF contract
- See extracted information and compliance checks
rules_version = '2';
service cloud.firestore {
match /databases/{database}/documents {
match /{document=**} {
allow read, write: if true;
}
}
}
For Production: Replace with authentication-based rules (see backend/firestore.rules)
From backend/.env.example:
# Gemini API
GEMINI_API_KEY=your-api-key
GEMINI_MODEL=gemini-2.0-flash
# Google Cloud
GOOGLE_CLOUD_PROJECT=legalmind-486106
GOOGLE_APPLICATION_CREDENTIALS=path/to/service-account.json (optional)
# Firestore
FIRESTORE_DATABASE=(default)
# Cloud Storage
GCS_BUCKET_NAME=legalmind-contracts
GCS_CONTRACTS_FOLDER=contracts
GCS_DOCUMENTS_FOLDER=generated-documents
# Application
APP_NAME=LegalMind
APP_ENV=development
DEBUG=true
API_HOST=0.0.0.0
API_PORT=8000
# Session Configuration
SESSION_TIMEOUT_MINUTES=60
MAX_TOKENS_PER_REQUEST=8192
# Rate Limiting
RATE_LIMIT_REQUESTS_PER_MINUTE=30
# Feature Flags
ENABLE_SEARCH_GROUNDING=true
ENABLE_THINKING_LOGS=true
ENABLE_CITATIONS=truegemini-hackathon/
├── backend/
│ ├── services/ # Core services (Gemini, Firestore, Storage)
│ ├── agents/ # Legal agent definitions
│ ├── tools/ # Analysis tools (14+)
│ ├── api/ # REST API endpoints
│ ├── managers/ # Business logic (ChatbotManager)
│ ├── config/ # Settings management
│ ├── main_new.py # Backend entry point
│ ├── .env.local # Local secrets (NOT in git)
│ ├── .env.example # Configuration template
│ └── firestore.rules # Security rules
│
├── frontend/
│ ├── app/
│ │ ├── chat/ # Chat interface
│ │ ├── contracts/ # Contract management
│ │ ├── dashboard/ # Risk dashboard
│ │ ├── reports/ # Reports view
│ │ ├── thinking-logs/ # Agent reasoning
│ │ └── api/ # API proxy routes
│ ├── components/ # Reusable UI components
│ ├── lib/ # Utility functions
│ ├── globals.css # Global theme (legal blue)
│ └── package.json
│
├── docs/
│ ├── README.md # Project overview
│ ├── IMPLEMENTATION_PLAN.md
│ ├── FRONTEND_CHANGES.md
│ ├── CODE_TRANSFORMATION_GUIDE.md
│ └── PROJECT_STATUS.md
│
├── ENV_SETUP.md # Environment configuration guide
├── FIRESTORE_SETUP.md # Firestore setup instructions
├── deploy_firestore_rules.py
└── deploy-firestore-rules.bat
- Test the Chat: Ask legal questions and see agents respond
- Upload Contracts: Test contract analysis workflow
- Check Compliance: Test compliance checking features
- View Reports: Generate and view legal documents
- Monitor Thinking: View agent reasoning process in thinking logs
- Keep
.env.localsecret: Never commit to git or share API keys - Production Rules: Update Firestore rules before production deployment
- Rate Limits: API has 30 requests/minute rate limit for development
- Token Limits: 8192 max tokens per request to Gemini
- Session Timeout: Sessions expire after 60 minutes of inactivity
- Check
GEMINI_API_KEYis valid in.env.local - Verify
GOOGLE_CLOUD_PROJECT=legalmind-486106is correct - Ensure Firestore security rules are deployed
- Check backend is running on http://localhost:8000
- Verify Firestore rules are deployed (allow read/write)
- Check browser console for specific error messages
- Verify Project ID is
legalmind-486106 - Ensure security rules are published
- Check internet connection to Google Cloud
- Visit http://localhost:8000/docs (not /swagger)
- Wait 5 seconds for OpenAPI schema to load
- Check backend logs for errors
- API Docs: http://localhost:8000/docs
- Firebase Console: https://console.firebase.google.com/project/legalmind-486106
- Google Cloud Console: https://console.cloud.google.com/project/legalmind-486106
- Gemini API Docs: https://ai.google.dev/docs
LegalMind is ready for development and testing! 🎉
Start building amazing legal AI features.