You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
ClauseGuard is a full-stack AI application that analyzes legal contracts for non-lawyers. Upload a PDF or DOCX, and the system segments it into clauses, classifies the contract type, scores each clause for risk across 5 dimensions, generates safe rewrites, and produces a negotiation action plan.
🎬 A demo video of the app can be found at https://github.com/rj9884/clauseGuard/blob/main/frontend/public/demo-video/ClauseGaurd(1).mp4.
Scoring:overall_score = arithmetic mean of all clause scores. Clauses returned sorted descending by score.
Rate limiting: Batches of 4 clauses processed concurrently via asyncio.gather(), with a 15-second pause between batches for Gemini free-tier compliance.
Clause Browser
Feature
Implementation
Color-coded cards
2px left border — red (Critical), orange (High), yellow (Medium), green (Low)
Default sort
Descending by risk_score (inherits backend sort)
Search
String.includes() on original_text; matches highlighted via regex + <mark> tag
Filter
useMemo hook on risk level — no re-fetch
Expand
Click to reveal full text, explanation, and safe rewrite diff
Safe Rewrite & Diff View
Aspect
Detail
Availability
All High and Critical clauses
Display
Two-column panel: original (red-tinted) vs. suggested (green-tinted)
Copy
navigator.clipboard.writeText() hover button
Generation
Produced in the same Gemini call as the risk score — no extra latency
Negotiation Action Plan
Aspect
Detail
Source
Pure Python post-processing of analyzed clauses — no additional AI call
Trigger
Any clause with risk_level in ["High", "Critical"]
Output
Quoted talking points with severity badge and clause reference
Red Flags Panel
Aspect
Detail
Sources
Clauses with risk_score ≥ 80 + compliance_flags[] from backend
Tab badge
Shows total count of High + Critical clauses
Display
Danger-bordered cards (critical) and warning-bordered cards (compliance)
Contract Comparison
Step
Detail
Input
Two files (file1 = original, file2 = negotiated) via multipart/form-data
Embeddings
sentence-transformers/all-MiniLM-L6-v2 encodes both clause lists
Output
delta_score, human-readable message, and changes[] array per modified clause
Display
Side-by-side diff cards color-coded by change type (Risk Decreased / Increased / Neutral)
Other Features
Feature
Detail
PDF Export
Client-side only via jsPDF — no server round-trip; includes score, summary, and filename
Local History
Analyses serialized to localStorage under analysis_<id>; last 5 shown on homepage with color-coded scores
Demo Mode
?demo=true query param loads a hardcoded mock payload — works with no backend or API key
Tech Stack
Backend
Library
Purpose
FastAPI + uvicorn
Async REST API
PyMuPDF (fitz)
PDF text extraction
python-docx
DOCX extraction
spaCy en_core_web_sm
Clause segmentation
facebook/bart-large-mnli
Zero-shot contract classification
gemini-2.0-flash (Google GenAI)
Per-clause risk analysis & summary
all-MiniLM-L6-v2
Semantic embeddings for contract comparison
Frontend
Library
Purpose
React 18 + TypeScript
Component UI
Vite
Build tool & dev server
Tailwind CSS
Styling
Recharts
RadarChart for risk visualization
jsPDF
Client-side PDF export
react-router-dom v6
Client-side routing
API Reference
POST /upload
Body
multipart/form-data — field file (PDF or DOCX, ≤ 10 MB)