Inspiration
Most people sign contracts they don't fully understand — lease agreements, freelance contracts, NDAs, employment offers. Legal jargon is deliberately dense, and hiring a lawyer for every document isn't realistic. We wanted to build something that acts like a brilliant legal friend in your pocket: one that reads the fine print for you, flags the dangerous clauses, and explains them in plain English.
What it does
ClauseGuard is an iOS app that uses AI to scan and analyse contracts in seconds.
- 📄 Upload or photograph any contract (PDF, image, or typed text)
- 🛡️ Get a Safety Score (0–100) with a risk tier: Low / Moderate / High / Dangerous
- 🚩 See every red-flag clause highlighted with a plain-English explanation and a suggested fix
- ✅ See the protective clauses that are actually working in your favour
- 💬 Ask follow-up questions in a chat interface powered by Gemini
- 🔗 Tap cited sources — legal references are interactive and link out to real documents
- 🎙️ Voice input for hands-free queries
- 📤 Export analysis as PDF or share it
How we built it
The core stack is Swift + SwiftUI with an MVVM architecture and Core Data for local persistence.
Contract analysis uses Gemini 2.0 Flash in JSON mode — we engineered a structured prompt that returns a typed ContractAnalysisResult with a safety score, one-sentence summary, and an array of ContractClause objects (each with type, title, quote, explanation, and fix). Camera/image OCR and conversational chat run on Gemini 2.5 Flash.
The safety score is rendered with an animated radial gauge. Clause cards use a custom design system with haptic feedback and skeleton loading states. Related legal topics, source citations, and suggested follow-up questions are each handled by dedicated micro-services calling the Gemini API.
Challenges we faced
- Structured JSON from LLMs: Getting Gemini to reliably return well-formed JSON for every contract type required careful prompt engineering and retry logic with exponential backoff.
- Swift type safety with async streams: Using
AsyncThrowingStreamfor streaming responses required careful error type handling — Swift's type system is unforgiving, and a shadowedErrortype caused cascading build failures we had to methodically untangle. - OCR accuracy on low-quality scans: Contract photos are often crumpled or poorly lit. We combined Gemini's vision capabilities with pre-processing hints in the prompt to improve extraction accuracy.
- Scope: Building a production-quality iOS app — with animations, haptics, voice input, export, onboarding, and a full design system — in hackathon time was genuinely hard.
What we learned
- How to use Gemini's JSON mode to extract structured legal data reliably
- How to architect a multi-service SwiftUI app cleanly with MVVM
- That the hardest part of legal AI isn't the AI — it's making the output trustworthy and legible to non-lawyers
What's next for ClauseGuard
- Side-by-side clause comparison across multiple contracts
- Negotiation coach mode — auto-draft redlines
- Android version
- Direct integration with DocuSign / Google Drive
Log in or sign up for Devpost to join the conversation.