🧠 Inspiration

It all started when I was reviewing an employment contract for a new job offer and found that I was struggling to understand the legal jargon.

I realized how difficult it can be for individuals to truly understand complex legal language. Legal documents are often dense, time-consuming, and intimidating to review. Most people struggle to grasp key clauses and identify potential risks, particularly in employment or freelance agreements.

That’s where Lexi comes in: a multi-agent AI legal assistant designed to make contract analysis clear, accessible, and easy to understand for individuals.

Lexi’s vision is to help people understand any legal document, anywhere in the world. For now, it’s trained specifically on employment contracts in English under German law, as part of this project’s scope.

💡 What it does

Here’s how it works:

  • You upload your employment, freelance, or NDA contract.
  • Lexi analyzes each clause using multiple AI agents.
  • On the frontend, Lexi streams the analysis in real time for a smooth, interactive experience.
  • It highlights potential risks, compares clauses to standard legal documents, and explains everything in plain, human-friendly language.

In short, Lexi makes legal document understanding faster, clearer, and even enjoyable.

🏗️ How we built it

The project runs two services (frontend and backend running multiple AI agents) deployed on Google Cloud Run.

Frontend (React)

  • Runs on Google Cloud Run via Google AI Studio
  • Allows users to upload contracts and view clause-by-clause analysis.
  • All data is processed locally — no documents or personal data are stored.
  • Google AI Studio was used to build the UI and deploy it to Cloud Run

Backend (Google ADK)

  • Deployed on Google Cloud Run for scalable, serverless execution.
  • Handles file uploads and automatically extracts text from PDF documents.
  • Orchestrates a team of AI agents, powered by Gemini as the LLM, that perform clause-level extraction, compare each clause with standard legal clauses stored in Firestore, and analyze potential risks.
  • Exposes an API (via FastAPI) that enables seamless communication between the frontend and the agent system.

AI Agent System (Google ADK)

Agent Role
RootOrchestratorAgent Coordinates all specialized agents
SequentialAgent Ensures agents process clauses in the correct order
ClauseExtractorAgent Identifies and extracts each clause from the document
StandardClauseRetriever Finds reference clauses using Firestore embeddings
ComparisonAgent Detects deviations from standard clauses
RiskAnalysisAgent Explains potential issues in plain language

🧭 Agents work collaboratively via an orchestrator and shared state.

Privacy & Safety

  • Lexi’s agents are carefully instructed through their prompts to minimize hallucinations.
  • Each agent’s prompt explicitly reminds the model to stay factual and informativenever to provide legal advice.
  • No data is ever saved. Everything runs in memory to preserve the privacy of the user and their legal documents.
  • The root agent includes built-in guardrails to prevent malicious inputs.

By combining Google Cloud Run, Google ADK, Firestore, and Gemini, Lexi transforms how individuals interact with their legal documents — making legal understanding faster, more accessible, and empowering for everyone.

🚧 Challenges we ran into

  • Researching and preparing standard legal documents for embedding.
  • Using Firestore effectively for storing and retrieving clause embeddings.
  • Coordinating ADK, FastAPI, and embeddings in a single workflow.
  • Carefully crafting clear and focused prompts for each agent to prevent hallucination and unintended legal advice.
  • Integrating guardrails to prevent malicious usage and make the app production-ready.
  • Building a modern,engaging UI that breaks away from the traditional look of legal apps.

🏆 Accomplishments that we’re proud of

  • Combining Gemini models, Google ADK, Firestore to create an AI app that improves a process and solves a real-world problem.
  • Using Cloud Run to deploy services seamlessly

📚 What we learned

  • How to orchestrate and deploy multi-agent systems on Google Cloud Run.
  • How to use Firestore embeddings for clause retrieval and semantic comparisons.
  • How to build end-to-end applications powered by AI agents to improve real-world processes.
  • How to integrate guardrails in a multi-agent app for safety.

🚀 What’s next for Lexi

  • Expand support for more document types (e.g. leases, terms of service) and countries.
  • Add conversational follow-ups — allowing users to ask Lexi specific legal questions.
  • Integrate more languages to make legal understanding accessible globally.
  • Explore secure user authentication for saved sessions and history.

Built With

Share this project:

Updates