When I first heard about the Google Cloud Run Hackathon, I was intrigued by the AI Agent track and the potential of Cloud Run. Around the same time, I was reviewing an employment contract for a new job offer, and I realized how difficult it can be for individuals to understand complex legal language. That’s when the idea for Lexi was born.
I created Lexi to make legal analysis more accessible and easy to understand. Powered by multi-agent orchestration and Google’s ADK framework, Lexi reads, analyzes, and explains contract clauses in clear, human-friendly language — turning dense legal text into insights anyone can grasp.
⚙️ How It Works
Here’s what Lexi can do:
✍️ AI-powered Clause Analysis
Analyzes each contract clause for meaning, risk, and compliance.
📚 Standard Clause Comparison
Compares your clauses to reference legal standards using embeddings stored in Firestore.
🧪 Risk Detection & Explanation
Highlights potential risks and explains them in plain English.
🧩 Multi-Agent Orchestration
Specialized agents (for extraction, comparison, and risk analysis) work together under a root orchestrator.
🎓 Plain-Language Summaries
Turns complex legalese into actionable insights.
🎥 Real-Time Streaming UI
The frontend streams analysis results live as they’re generated — for a fast, interactive experience.
🗣️ Privacy by Design
No data stored — all processing happens in memory.
📈 Guardrails & Rate Limiting
Protects against unsafe inputs and API abuse.
📤 Seamless Delivery
Clean React frontend and FastAPI backend — both running on Google Cloud Run.
🧱 System Architecture
┌───────────────────────────────┐
│ Frontend (React) │
│-------------------------------│
│ • Upload contract (PDF/Text) │
│ • View clause analysis (live) │
│ │
└──────────────┬────────────────┘
│
JSON POST /contracts/analyze
│
▼
┌───────────────────────────────┐
│ FastAPI Backend │
│ (Runs on Cloud Run) │
│-------------------------------│
│ 1️⃣ Receives contract payload │
│ 2️⃣ Extracts text (if PDF) │
│ 3️⃣ Sends to CoreOrchestrator │
│ 4️⃣ Streams structured JSON │
│ chunks back to frontend │
└──────────────┬────────────────┘
│
▼
┌────────────────────────────────────────────┐
│ Google ADK Agent System (Vertex AI) │
│--------------------------------------------│
│ 🧭 CoreOrchestrator (LLM) │
│ ├─ ClauseExtractorAgent (LLM) │
│ ├─ StandardClauseRetriever (Embed) │
│ ├─ ClauseComparisonAgent (LLM) │
│ └─ RiskAnalysisAgent (LLM) │
│ │
└────────────────────────────────────────────┘
│
▼
Streamed JSON → FastAPI → React
🧩 Stack Overview
- Frontend: React (Cloud Run)
- Backend: FastAPI (Cloud Run)
- Storage: Firestore (for embeddings)
- LLMs: gemini-embedding-001, gemini-2.0-flash
- OCR: In-memory PDF text extraction
- Containerization: Docker
- Deployment: Google Cloud Run
🤖 Multi-Agent System
| Agent | Role |
|---|---|
| RootOrchestratorAgent | Coordinates all specialized agents |
| SequentialAgent | Ensures ordered clause processing |
| ClauseExtractorAgent | Extracts clauses from the contract |
| StandardClauseRetriever | Retrieves reference clauses from Firestore embeddings |
| ComparisonAgent | Detects deviations from standard clauses |
| RiskAnalysisAgent | Explains potential issues in plain language |
All agents collaborate through an orchestrator and shared state — creating a flexible and extensible system for document intelligence.
🧠 What I Learned
- How to orchestrate multi-agent systems using Google ADK
- How to integrate embeddings with Firestore for semantic retrieval
- How to deploy AI workloads on Google Cloud Run efficiently
- How to design real-time streaming UIs with FastAPI and React
🏆 Accomplishments
✅ Built a complete AI-driven pipeline using ADK, FastAPI, and Firestore
✅ Designed and deployed a full multi-agent architecture on Cloud Run
✅ Learned to use Google ADK for intelligent, modular agent design
🚀 What’s Next
🔹 Expand to more document types (leases, NDAs, terms of service)
🔹 Add conversational Q&A (“Ask Lexi about clause 5”)
🔹 Support multiple languages for global accessibility
🔹 Explore secure authentication and saved session histories
Top comments (0)