This is a submission for the Algolia Agent Studio Challenge: Consumer-Facing Conversational Experiences
What I Built
ContractCompass is an AI-powered contract analysis tool that turns legal jargon into plain English through natural conversation. Think of it as having a friendly lawyer friend who can review your contract over coffee, except this friend never gets tired, works 24/7, and doesn't charge $400/hour.
The Problem
Most people sign contracts they don't fully understand. Employment agreements, rental leases, SaaS terms—they're all written in dense legal language that assumes you went to law school. By the time you realize that "perpetual, irrevocable, worldwide license" means the company owns your weekend projects forever, you've already signed away your rights.
According to research, over 90% of people don't read terms and conditions before accepting them. It's not laziness. These documents are genuinely incomprehensible to the average person. A typical employment contract might be 15 pages of legal clauses that take hours to parse, assuming you even know what to look for.
The Solution
ContractCompass solves this through dialogue-based AI interaction. Instead of drowning you in legal analysis reports, it lets you have a natural conversation about your contract:
- "What are the red flags here?"
- "Can you explain this termination clause like I'm five?"
- "Is this non-compete actually enforceable?"
- "What should I negotiate before signing?"
The AI agent responds in real-time with contextual answers grounded in a curated database of contract clauses, powered by Algolia Agent Studio's semantic search capabilities.
Key Capabilities
Conversational AI Interface - Chat naturally with the agent. No forms, no checkboxes, just questions and answers.
Intelligent Risk Detection - Every clause gets analyzed and scored on a three-tier system (Low, Medium, High risk) with visual indicators.
Plain English Translations - Legal jargon becomes "here's what this actually means for you."
Industry Comparisons - The agent explains whether clauses are standard practice or unusual outliers worth negotiating.
Rich Visual Analysis - For deep dives, the agent generates structured analysis cards with prevalence bars, red flag lists, and detailed reasoning.
Demo
Live Demo: https://contractcompass.varshithvhegde.in/
No login required. No credit card. Just upload a contract (or try one of the built-in samples) and start asking questions.
How It Feels to Use
1. Upload is effortless
Drag and drop a PDF, paste text, or click one of the sample contracts. I've included four pre-loaded examples:
- Friendly Startup Offer (Low Risk) - A well-balanced employment agreement with fair terms
- Red Flag Employment Contract (High Risk) - Includes unilateral salary cuts, 24-month lock-in, overbroad IP assignment, 3-year non-compete, and $500K liquidated damages
- Predatory Rental Agreement (High Risk) - Non-refundable deposits, tenant pays for ALL repairs, no-notice landlord entry, uncapped rent increases
- Reasonable SaaS Agreement (Low Risk) - Standard business terms with mutual protections
2. The interface splits
Your contract appears on the left for reference, chat on the right. You can always scroll back to check what clause the AI is talking about.
3. Suggested prompts guide you
Six smart buttons help you get started:
- Full Risk Analysis
- Find red flags
- Explain in plain English
- What should I negotiate?
- Compare to standards
- Is this enforceable?
4. Streaming responses feel natural
The AI types back to you in real-time, token by token, like a real conversation. No waiting for a complete response to load. You see the analysis unfold naturally.
How I Used Algolia Agent Studio
Algolia Agent Studio is the intelligence engine that makes ContractCompass possible. Here's how it powers the entire conversational experience.
The Index: A Knowledge Base of Contract Clauses
I created an Algolia index called contract_clauses containing 50+ curated contract clauses across four contract types (employment, rental, SaaS, freelance). Each record includes:
- clause_text - The full text of the clause
- clause_type - Category (termination, compensation, non-compete, etc.)
- contract_type - Employment, rental, SaaS, or freelance
- industry - Tech, real estate, or general
- prevalence_score - A 0-1 score indicating how common this clause is
- risk_level - Low, medium, or high
- plain_english - Simple explanation for non-lawyers
- red_flags - List of concerning aspects
- standard_version - What a fair version would look like
- legal_implications - Real-world impact of accepting the clause
For example, a "predatory non-compete" clause record looks like this:
{
"objectID": "emp-nc-003",
"clause_text": "Employee agrees not to work for any competing business...",
"clause_type": "non_compete",
"contract_type": "employment",
"industry": "tech",
"prevalence_score": 0.2,
"risk_level": "high",
"plain_english": "You can't work for competitors for 3 years across all of North America",
"red_flags": ["Unreasonably broad geographic scope", "Excessive duration"],
"standard_version": "Typically 6-12 months within 50 miles of office",
"legal_implications": "May prevent you from working in your field"
}
How Retrieval Powers the Conversation
When a user uploads a contract and starts asking questions, here's what happens behind the scenes:
1. Semantic Clause Matching
The Algolia agent retrieves semantically similar clauses from the index to provide context-aware responses. For example, if someone asks "Is this non-compete fair?", the agent:
- Identifies the non-compete clause in the uploaded contract
- Searches the index for similar non-compete clauses
- Compares the uploaded clause against standard versions
- Explains whether it's typical or unusually restrictive
2. Contract Type Detection
The agent automatically identifies the type of contract (employment, rental, SaaS, etc.) based on the language and clauses present, then adjusts its analysis accordingly. An employment contract gets compared against employment standards, not rental standards.
3. Prevalence-Based Risk Assessment
Using the prevalence scores from the indexed data, the agent can say things like:
- "This termination clause is standard. About 95% of tech employment contracts include similar terms"
- "This security deposit policy is unusual. Only 15% of rental agreements make deposits non-refundable"
4. Standard Version Recommendations
When a clause is problematic, the agent doesn't just say "this is bad." It shows what a fair version would look like:
"The current non-compete restricts you for 3 years across North America. A standard tech industry non-compete is typically 6-12 months within 50 miles of the office."
Making the Agent Conversational
The key to making ContractCompass feel natural was teaching the agent to think like a helpful friend, not a legal robot. I crafted prompts that guide it to:
Speak like a human - Use simple language. Avoid legal jargon unless explaining it. Be conversational but professional.
Be honest about risks - If a clause is predatory, say so clearly. Don't sugarcoat problematic terms.
Ground everything in data - Always search the contract_clauses index for similar examples. Compare the user's clause against standard versions and explain how it differs from typical industry practice.
Provide actionable advice - Don't just identify problems. Suggest what to negotiate and how to approach it.
This approach ensures every response is both friendly and useful, backed by real contract data rather than generic advice.
Why Fast Retrieval Matters
Algolia's speed and semantic search capabilities are critical to making ContractCompass feel like a real conversation rather than a clunky Q&A bot.
Speed Creates Natural Dialogue
When someone asks "What are the red flags in this contract?", they expect an answer within seconds, not minutes. Algolia's sub-50ms search latency means the agent can:
- Retrieve relevant clause examples instantly
- Stream responses token-by-token without lag
- Handle follow-up questions in the same conversation thread
- Maintain context across multiple queries
If retrieval took 5-10 seconds per query, users would lose patience. The conversation would feel broken. Fast retrieval makes the experience feel fluid and natural.
Contextual Retrieval Enables Nuanced Analysis
Algolia's semantic search doesn't just match keywords. It understands meaning. This is crucial for contract analysis because:
Legal language varies widely
A non-compete clause might say "Employee shall not engage in competitive activities" or "You agree not to work for rival companies." These are semantically similar but textually different. Algolia's vector-based search matches them both.
Users ask in natural language
Someone might ask "Can they really fire me for any reason?" which should match clauses about "at-will employment" or "termination without cause." Semantic search bridges this gap.
Context matters
A liability cap of $100K might be reasonable in a $10K/year SaaS contract but predatory in a $500K enterprise agreement. By retrieving similar contracts in the same industry and price range, the agent provides context-aware analysis.
Retrieval Grounds Responses in Real Data
One of the biggest risks with AI agents is hallucination. Making up plausible-sounding but incorrect information. By grounding every response in retrieved data from the curated index, ContractCompass avoids this problem.
When the agent says "This non-compete is unusually restrictive," it's not guessing. It's comparing the uploaded clause against the prevalence scores and standard versions in the index. When it explains what a fair clause looks like, it's showing you actual examples from the database.
This retrieval-augmented generation (RAG) approach makes the agent both reliable and trustworthy.
The Impact on User Experience
From a user perspective, fast contextual retrieval translates to:
Confidence in the analysis - "This isn't just an AI's opinion, it's based on real contract data"
Immediate answers - "I can get my questions answered in real-time without waiting"
Conversational flow - "It feels like talking to a human expert who knows contract law"
Actionable insights - "I now know exactly what to negotiate before signing"
Without Algolia's speed and semantic capabilities, ContractCompass would be a generic chatbot that gives vague, unhelpful advice. With them, it's a genuinely useful tool that empowers people to understand and negotiate their contracts.
Technical Architecture
Frontend (React + TypeScript)
The interface is built with React 18 and TypeScript for type safety. I chose a modern stack that prioritizes performance and developer experience:
- UI Library: Tailwind CSS + shadcn/ui components for a clean, professional look
- State Management: React hooks for local state (no complex state library needed)
- Markdown Rendering: react-markdown for rich text in chat responses
AI Agent (Algolia Agent Studio)
The chat interface calls Algolia Agent Studio directly from the frontend. This direct integration means:
- Real-time streaming responses that appear token-by-token
- No backend proxy needed for chat, which reduces latency
- Full conversation history sent with each request for contextual follow-ups
Search Index (Algolia)
The contract_clauses index contains 300+ curated clauses. Each clause is enriched with metadata (prevalence scores, risk levels, plain English explanations) that the agent uses to provide contextual analysis.
PDF Processing
When users upload PDFs, the text extraction happens server-side using Google Gemini 2.5 Flash. The flow is:
- User uploads PDF via drag-and-drop
- PDF converts to base64 on the client
- Base64 data sent to serverless function
- Function calls Gemini API for text extraction
- Extracted text returns to the frontend
- Text loads into chat interface for analysis
Backend (Serverless Functions)
Four serverless functions handle specific tasks:
- extract-pdf - PDF text extraction using Gemini
- analyze-contract - Clause parsing and analysis
- search-clauses - Direct Algolia index queries
- seed-algolia - Index population with curated data
Design Decisions
Split-Screen Layout
I chose a split-screen design (contract on left, chat on right) because users need to reference the original text while discussing it. It feels more collaborative, like reviewing a document with someone. Mobile users get a stacked layout that still works well.
Color-Coded Risk Levels
Risk levels use universal color psychology:
- Green - Safe, standard terms
- Amber - Caution, worth discussing
- Red - Danger, likely problematic
These colors are consistent across risk badges, prevalence bars, and analysis cards. You can glance at a clause and immediately understand its risk level.
Suggested Prompts
Not everyone knows what questions to ask about a contract. The six suggested prompts serve as:
- Onboarding - Showing users what's possible
- Efficiency - Common questions answered with one click
- Discovery - Revealing features users might not know about
Streaming Responses
Token-by-token streaming makes the AI feel more human and less like a loading bar. It also provides immediate feedback that the system is working. Users don't stare at a blank screen wondering if anything is happening.
Challenges and Learnings
Challenge 1: Balancing Legal Accuracy with Accessibility
Legal language exists for precision. Simplifying it risks losing important nuances. I solved this by:
- Providing both the original clause text and plain English side-by-side
- Including detailed "legal implications" sections for those who want depth
- Being honest about limitations (the disclaimer reminds users this isn't legal advice)
Challenge 2: Handling Diverse Contract Formats
Contracts vary wildly in structure. Some are 2 pages, others are 50. Some use headers, others are wall-to-wall text. The PDF extraction with Gemini handles this by:
- Preserving structure where possible
- Extracting text even from scanned/image PDFs
- Cleaning up formatting artifacts
Challenge 3: Preventing AI Hallucination
Early versions sometimes invented red flags that didn't exist. The solution was retrieval-augmented generation. Every analysis is now grounded in retrieved clause data from the index. The agent can only reference what it finds in the search results.
Challenge 4: Making Risk Scores Meaningful
A simple "high risk" label isn't actionable. I added:
- Prevalence scores - "Only 20% of contracts include this"
- Standard versions - "Here's what fair looks like"
- Specific red flags - "This clause is concerning because..."
These additions turn a vague warning into specific, actionable information.
Export Analysis as PDF
Let users download a full risk report they can share with lawyers or keep for their records. Make it official and presentable.
What I Learned
Building ContractCompass taught me that the best AI tools don't feel like AI tools. They feel like helpful conversations with knowledgeable friends. The key is combining:
- Fast, semantic search that finds the right information instantly
- Thoughtful prompting that guides the AI to be helpful, not robotic
- Real data that grounds responses in facts, not hallucinations
- Clear design that makes complex information accessible
Algolia Agent Studio made the first part possible. The rest was about understanding what people actually need when facing a contract: clarity, confidence, and actionable advice.
Conclusion
ContractCompass demonstrates how conversational AI powered by fast, semantic search can democratize access to legal understanding. By combining Algolia Agent Studio's retrieval capabilities with a thoughtfully designed user experience, it transforms contract analysis from an intimidating expert task into an accessible conversation.
The key insight: people don't need to become lawyers to understand their contracts. They just need the right questions answered in language they can understand, backed by real data about what's standard and what's not.
Try it yourself: https://contractcompass.varshithvhegde.in/
Built With
Powered by:
- Algolia Agent Studio - Conversational AI with semantic search
- React + TypeScript - Frontend framework
- Tailwind CSS + shadcn/ui - UI components
- Google Gemini - PDF text extraction
GitHub:
ContractCompass 🧭
AI-Powered Contract Analysis for Non-Lawyers
Chat with AI to understand your contract. Identify risks, get plain-English explanations, and learn what to negotiate — powered by Algolia Agent Studio.
📋 Table of Contents
- Overview
- Live Demo
- Key Features
- Architecture
- Technology Stack
- Algolia Agent Studio Integration
- How It Works
- Contract Types Supported
- Sample Contracts
- Risk Assessment System
- Conversational AI Capabilities
- Structured Risk Analysis
- PDF Extraction
- Algolia Search Index
- UI/UX Design
- Edge Functions
- Security
- Getting Started
Overview
ContractCompass is an intelligent contract analysis tool designed to help everyday people — not lawyers — understand legal documents before they sign. Users upload or paste a contract, then have a real-time conversation with an AI agent that identifies risky clauses, explains legal jargon in plain English, and compares terms against industry standards.
The AI agent is powered by Algolia Agent Studio, which provides semantic search and retrieval of similar contract clauses…
ContractCompass is not a substitute for professional legal advice. Always consult a qualified attorney for legal matters.








Top comments (2)
Great job, Varshith! 🔥
Thankss
Some comments may only be visible to logged-in visitors. Sign in to view all comments.