Google Cloud Run Hackathon: Building Lexi — a Multi-Agent AI Legal Assistant

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 …


This content originally appeared on DEV Community and was authored by Audrey Kadjar

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


This content originally appeared on DEV Community and was authored by Audrey Kadjar


Print Share Comment Cite Upload Translate Updates
APA

Audrey Kadjar | Sciencx (2025-11-07T07:42:40+00:00) Google Cloud Run Hackathon: Building Lexi — a Multi-Agent AI Legal Assistant. Retrieved from https://www.scien.cx/2025/11/07/google-cloud-run-hackathon-building-lexi-a-multi-agent-ai-legal-assistant/

MLA
" » Google Cloud Run Hackathon: Building Lexi — a Multi-Agent AI Legal Assistant." Audrey Kadjar | Sciencx - Friday November 7, 2025, https://www.scien.cx/2025/11/07/google-cloud-run-hackathon-building-lexi-a-multi-agent-ai-legal-assistant/
HARVARD
Audrey Kadjar | Sciencx Friday November 7, 2025 » Google Cloud Run Hackathon: Building Lexi — a Multi-Agent AI Legal Assistant., viewed ,<https://www.scien.cx/2025/11/07/google-cloud-run-hackathon-building-lexi-a-multi-agent-ai-legal-assistant/>
VANCOUVER
Audrey Kadjar | Sciencx - » Google Cloud Run Hackathon: Building Lexi — a Multi-Agent AI Legal Assistant. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2025/11/07/google-cloud-run-hackathon-building-lexi-a-multi-agent-ai-legal-assistant/
CHICAGO
" » Google Cloud Run Hackathon: Building Lexi — a Multi-Agent AI Legal Assistant." Audrey Kadjar | Sciencx - Accessed . https://www.scien.cx/2025/11/07/google-cloud-run-hackathon-building-lexi-a-multi-agent-ai-legal-assistant/
IEEE
" » Google Cloud Run Hackathon: Building Lexi — a Multi-Agent AI Legal Assistant." Audrey Kadjar | Sciencx [Online]. Available: https://www.scien.cx/2025/11/07/google-cloud-run-hackathon-building-lexi-a-multi-agent-ai-legal-assistant/. [Accessed: ]
rf:citation
» Google Cloud Run Hackathon: Building Lexi — a Multi-Agent AI Legal Assistant | Audrey Kadjar | Sciencx | https://www.scien.cx/2025/11/07/google-cloud-run-hackathon-building-lexi-a-multi-agent-ai-legal-assistant/ |

Please log in to upload a file.




There are no updates yet.
Click the Upload button above to add an update.

You must be logged in to translate posts. Please log in or register.