How vaishnavi-ctrl-jpg/clauseguard-ai-legal-document-auditor-grounded-clause-navigator works
ClauseGuard is a legal-document auditing and navigation app. Users submit contract text for risk scoring, plain-English clause explanations, and verified citations; they can also ask grounded questions or request fair replacement language and a draft negotiation email. The main API routes validate and protect requests, use cached AI-provider results, and verify citations for audits and Q&A. The README documents the principal UI capabilities and Gemini integration; source excerpts show route-level wiring. The page and provider implementations were not excerpted, so some UI and external-service links rely on README documentation.
Main entry points: analyze/route.ts Contract analysis · chat/route.ts Grounded Q&A · negotiate/route.ts Counter-proposal · factory.ts Provider factory
Components 16
User experience
- Auditor dashboard
src/app/page.tsx - Negotiation modal
src/components/NegotiationModal.tsx
Legal workflows
- Contract analysis
src/app/api/analyze/route.ts - Grounded Q&A
src/app/api/chat/route.ts - Counter-proposal
src/app/api/negotiate/route.ts - Citation verifier
src/lib/groundingVerifier.ts - Response cache
src/lib/cache.ts
AI providers
- Provider interface
src/lib/ai/provider.ts - Provider factory
src/lib/ai/factory.ts - Gemini provider
src/lib/ai/geminiProvider.ts - Demo provider
src/lib/ai/mockProvider.ts
Request safeguards
- Body validation
src/lib/validators.ts - Sanitize and throttle
src/lib/security.ts - API error mapping
src/lib/apiError.ts
Other components
- Contract user
- Google Gemini
Connections 27
- Contract user → Auditor dashboard: uses
README.md - Auditor dashboard → Contract analysis: submits contract
README.md - Auditor dashboard → Grounded Q&A: asks questions
README.md - Auditor dashboard → Negotiation modal: opens drafter
src/app/page.tsx - Negotiation modal → Counter-proposal: requests proposal
src/components/NegotiationModal.tsx - Contract analysis → Body validation: validates body
src/app/api/analyze/route.ts - Grounded Q&A → Body validation: validates body
src/app/api/chat/route.ts - Counter-proposal → Body validation: validates body
src/app/api/negotiate/route.ts - Contract analysis → Sanitize and throttle: sanitizes and throttles
src/app/api/analyze/route.ts - Grounded Q&A → Sanitize and throttle: sanitizes and throttles
src/app/api/chat/route.ts - Counter-proposal → Sanitize and throttle: throttles requests
src/app/api/negotiate/route.ts - Contract analysis → Response cache: reads and writes
src/app/api/analyze/route.ts - Grounded Q&A → Response cache: reads and writes
src/app/api/chat/route.ts - Counter-proposal → Response cache: reads and writes
src/app/api/negotiate/route.ts - Contract analysis → Provider factory: gets provider
src/app/api/analyze/route.ts - Grounded Q&A → Provider factory: gets provider
src/app/api/chat/route.ts - Counter-proposal → Provider factory: gets provider
src/app/api/negotiate/route.ts - Contract analysis → Citation verifier: verifies clauses
src/app/api/analyze/route.ts - Grounded Q&A → Citation verifier: verifies citations
src/app/api/chat/route.ts - Contract analysis → API error mapping: maps failures
src/app/api/analyze/route.ts - Grounded Q&A → API error mapping: maps failures
src/app/api/chat/route.ts - Counter-proposal → API error mapping: maps failures
src/app/api/negotiate/route.ts - Provider factory → Gemini provider: selects when configured
src/lib/ai/factory.ts - Provider factory → Demo provider: selects demo fallback
src/lib/ai/factory.ts - Gemini provider → Provider interface: implements
src/lib/ai/geminiProvider.ts - Demo provider → Provider interface: implements
src/lib/ai/mockProvider.ts - Gemini provider → Google Gemini: uses model
README.md