Inspiration
Inspiration
Professionals, freelancers, and startups regularly sign complex NDAs, vendor contracts, and terms of service without fully understanding buried predatory clauses—like uncapped indemnification, perpetual IP grabs, or hostile offshore arbitration. While modern LLMs can translate legalese into plain English, uploading confidential, legally privileged, or proprietary work contracts to third-party cloud servers violates confidentiality obligations and creates serious data privacy risks.
We built TermsTriage for #BuildHybridAI to eliminate the tradeoff between legal clarity and document confidentiality.
What it does
TermsTriage is a privacy-first hybrid AI contract and NDA reviewer that enforces a strict Privacy Boundary between your device and the cloud:
- Tier 1 — Zero-Egress Local Triage (
only_on_device): When you paste, upload, or select a contract, TermsTriage scans the entire document locally in your browser using Google Gemini Nano via the Firebase AI Logic SDK. It categorizes standard clauses (e.g., Confidentiality Scope, Severability, Governing Law) asLocal Standardand flags predatory or non-standard terms asHigh Risk—with zero cloud API cost and zero document egress. - Tier 2 — Isolated Cloud Escalation (
only_in_cloud): When a clause is flagged as predatory, TermsTriage never uploads your entire agreement. Only after explicit user confirmation does it extract and route that single isolated clause to Gemini 1.5 Flash for deep legal reasoning, plain-English risk translation, trap analysis, and a 1-Click Rewrite to a Fair Bilateral Clause that patches the contract in place. - Full Document Reader & Triage Matrix: Switch seamlessly between a full readable document view with inline risk highlights and a structured triage matrix, alongside an interactive TermsTriage Copilot grounded in the active contract.
- Developer Transparency (
Tech View): Toggle</> Tech Viewto inspect real-time hybrid telemetry, including active SDK inference modes, exact isolated payload byte counts vs. document bytes kept local, and Firebase App Check verification status. - Persistent Vault: Save finalized risk assessments and fair rewrites directly to Cloud Firestore under your authenticated account (
users/{uid}/contracts/{contractId}).
How we built it
- Hybrid AI Routing: Built around the Firebase AI Logic Hybrid Inference SDK, toggling explicitly between
mode: "only_on_device"(Chrome's Built-in AI Prompt API / Gemini Nano) for bulk document scanning andmode: "only_in_cloud"(Gemini 1.5 Flash) for user-approved clause escalations. We also engineered a deterministic client-side heuristics fallback so judges and users in browsers without experimental Chrome AI flags enabled can still test the full end-to-end triage workflow seamlessly. - Firebase Ecosystem: Integrated Firebase Authentication (Google Auth) for user identity, Cloud Firestore for persistent contract review history, and Firebase App Check to protect cloud escalation endpoints from unauthorized quota abuse.
- Frontend Architecture: Built with Next.js (App Router), React, TypeScript, Tailwind CSS, and Lucide React in a clean 3-column SaaS workspace featuring a consolidated Privacy Shield indicator, strict red/amber/green risk semantics, interactive diff comparisons, and Light/Dark mode support.
Challenges we ran into
- Balancing Privacy Transparency vs. UI Clutter: Early prototypes overloaded users with too many competing status badges and raw pipeline stats. We solved this by consolidating security guarantees into a single expandable Privacy Shield popover and moving raw byte/latency/mode telemetry behind a dedicated
Tech Viewtoggle. - Custom Contract Parsing: Real-world contracts vary wildly in formatting, headers, and section numbering. Refining our local clause-splitting parser to cleanly separate preambles from numbered sections—and keeping the Copilot strictly synced to newly uploaded documents—required iterative testing against multi-clause legal agreements.
- Truthful Hybrid Attribution: Ensuring the UI clearly differentiates when the cloud model is
Idle / Not Invoked(safe local clauses) versus actively invoked on an isolated risky clause so users always trust where their data is going.
Accomplishments that we're proud of
- Delivering a genuine clause-isolation privacy architecture where >90% of a confidential legal document never leaves the browser.
- Pairing risk detection with immediate utility via 1-Click Rewrite to Fair Clause, turning passive legal warnings into actionable counter-proposals.
- Building a resilient hybrid fallback loop and automated test suite so the live demo works reliably across both Gemini Nano–enabled Chrome setups and standard browsers.
What we learned
- Hybrid AI shines brightest when on-device models handle high-volume, privacy-sensitive filtering and cloud models handle high-complexity reasoning on minimal, user-approved payloads.
- Designing for trust in privacy-first AI requires visual restraint: clear boundaries, honest model attribution, and explicit user consent gates matter just as much as the underlying SDK routing.
What's next for TermsTriage
- Native PDF & DOCX Export with Tracked Changes: Export redlined contracts directly back to
.docxor.pdfafter applying 1-click fair rewrites. - Custom Legal Playbooks: Allow freelance agencies and legal teams to store custom local triage rules in Firestore (e.g., mandatory liability caps or preferred governing jurisdictions).
- Chrome Extension Mode: Bring TermsTriage directly into Gmail, DocuSign, and web-based vendor portals for instant on-page contract screening. ## What it does
How we built it
Challenges we ran into
Accomplishments that we're proud of
What we learned
What's next for TermsTriage
Built With
- chrome-built-in-ai
- firebase
- firebase-ai-logic
- firebase-app-check
- firebase-authentication
- firestore
- gemini-1.5-flash
- gemini-nano
- next.js
- react
- typescript