Project Vault
Executive Summary

ClauseGuard AI is an intelligent contract analysis platform engineered specifically to protect independent workers from predatory, vague, or financially damaging contract clauses. By combining natural language processing with automated risk scoring, the platform isolates dangerous terms in seconds and translates legalese into actionable insights.

The Market Opportunity & Problem

The global gig economy generates roughly $550–582 billion in annual revenue. The U.S. freelance workforce grew 90% between 2020 and 2024, with projections of 86.5 million U.S. freelancers by 2027. Despite this growth, independent workers remain acutely vulnerable to contractual exploitation.

$550–582B
Global gig economy, annual revenue
90%
U.S. freelance workforce growth, 2020–2024
86.5M
Projected U.S. freelancers by 2027
60%
Freelancers who sign without fully reading
71%
Freelancers who report trouble getting paid
$6,000
Average disputed amount, non-payment cases
$15,000
Average impact of broader contract disputes
81%
Median share of arbitration cost spent on legal defense
The Solution & North Star Metric

ClauseGuard AI democratizes contract review by automating the extraction and risk-scoring of critical clauses — Payment Terms, Scope of Work, Intellectual Property, Non-Competes, and more.

North Star Metric — "Time to Contract Confidence"
~4 hours
Manual clause-by-clause review
< 60 sec
With ClauseGuard AI
System Architecture

A modular, event-driven architecture built to balance performance, scalability, and strict data privacy.

Presentation
Next.js & React
Persistence & Auth
Supabase
AI & Vector Search
Gemini & pgvector
Client — Next.js on Vercel

Minimalist, value-first interface built with Tailwind CSS and shadcn/ui

API — Node/Express & Next Server Actions

PDF extraction service, with a Zod validation layer in front of it

Database — Supabase (PostgreSQL)

Relational tables for contracts & clauses, plus pgvector for rubric embeddings

Automation — n8n Pipeline

Async webhooks → aggregation → notification, without blocking the main backend thread

AI Engine — Gemini API

RAG pipeline producing structured JSON output

Security

Given the sensitive nature of legal documents, ClauseGuard AI follows fundamental cybersecurity practices aligned with the CIA Triad — Confidentiality, Integrity, Availability.

  • Strict MIME-type validation on all uploads
  • Prompt injection sanitization before documents reach the model
  • Secure storage in Supabase with aggressive data-retention lifecycle rules
The AI Risk Engine & Scoring

ClauseGuard AI doesn't just summarize documents — it runs a classification pipeline using Retrieval-Augmented Generation. Standard legal rubrics are embedded into a pgvector database, so the Gemini model grounds its analysis in established legal thresholds before assigning a risk profile.

Risk Score = ( Σ (Severityi × Weighti × Confidencei) ) / ( Σ Weighti )

This ensures highly critical clauses — like a perpetual IP transfer or an aggressive non-compete — dramatically elevate the risk score, prompting immediate review via highlighted Risk Cards.

Sprint Planning
SPRINT
0–1
Foundation & Architecture
Repo init, Next.js scaffolding, Supabase schema design (contracts, clauses, rubrics), GitHub CI/CD pipeline.
SPRINT
2
File Processing & Extraction
Minimalist UI upload zone, PDF parsing, chunking logic, secure file storage.
SPRINT
3
AI Pipeline & Vectorization
pgvector integration, Gemini prompt engineering, structured JSON extraction, RAG implementation.
SPRINT
4
Risk Engine & Dashboard
Weighted scoring algorithm, Risk Cards UI, accessibility checks, mobile-first dashboard styling.
SPRINT
5
Automation (n8n) & Polish
n8n webhook integrations, error logging, report generation, API latency optimizations.
Anticipated Engineering Challenges
  • Enforcing AI structured output — free-form LLM text is brittle for legal analysis, so strict JSON output via Gemini enables deterministic mapping directly into PostgreSQL.
  • Asynchronous orchestration — parsing and classifying 20-page contracts synchronously risks API timeouts, so the pipeline is offloaded to an event-driven n8n workflow.
  • Preventing hallucinations via vector search — pgvector retrieves trusted "good" and "bad" clause examples before prompting Gemini, reducing false positives.

Beyond the initial sprints, the long-term roadmap includes OCR for scanned documents, fine-tuned legal models, a Word plugin integration, and multi-jurisdictional rubrics to support freelancers operating globally.