← Back to projects

03 / Applied AI · Legal technology

LexGuard

A contract-intelligence prototype that extracts risky clauses and converts them into plain-language consequences, obligation timelines, and negotiation prompts.

Role

Hackathon prototype · repository owner

Status

Prototype · live demo available · source available

Main technologies
  • TypeScript
  • React
  • Express
  • Gemini
  • Vertex AI
  • Vite
Architecture illustrationLexGuard
Verified repository workflow: supported files or pasted text go to the Express analysis boundary, Gemini returns structured JSON, and server normalization prepares a predictable report stored for the browser session.

The problem

Legal and quasi-legal documents can contain one-sided obligations, broad rights assignments, renewals, arbitration terms, or liability exposure that are difficult to spot before signing.

A generic summary is not enough: the output has to preserve source excerpts, separate severity from confidence, and make model uncertainty visible.

The solution

The React interface accepts pasted text, common document formats, and supported images. An Express endpoint sends a structured risk prompt to Gemini through Vertex AI or the Gemini Developer API.

The server normalizes and clamps the returned JSON before the UI renders severity-based findings, consequences, scenarios, obligations, negotiation questions, and safer wording.

01

Keep model credentials server-side

Production uses the Cloud Run service identity with Vertex AI; local development can use a server-only Gemini key. The frontend never receives provider credentials.

02

Design around a report schema

The prompt requests strict JSON and the server normalizes severities, scores, and missing fields so the interface does not depend on free-form model prose.

03

Preserve a deterministic demo path

A clearly labelled sample fallback keeps the product explainable without an API key; it is not presented as analysis of the uploaded document.

Technical challenges

  1. Extracting usable text across document and image formats before model analysis.
  2. Turning probabilistic model output into a stable, readable risk-report contract.
  3. Communicating legal and privacy boundaries without presenting generated analysis as professional legal advice.

Testing and reliability

  1. Server normalization clamps scores, normalizes severity labels, and supplies safe structural fallbacks.
  2. Deterministic analyzer tests run without depending on live provider output.
  3. The public methodology and legal-awareness panels explain how findings are produced and how they should be reviewed.
  4. Credentials stay outside the browser bundle and local environment files remain uncommitted.

04 / Current limitations

What the project does not claim.

  • Model output can miss clauses or misclassify risk and must be checked against the quoted source text.
  • Submitted documents may be sent to the configured Gemini service; confidential material requires an appropriate deployment and provider configuration.
  • This is a hackathon prototype for legal awareness, not legal advice or an audited contract-review product.

05 / Next improvements

What I would build next.

  • Add a document-retention policy and clearer deletion controls.
  • Build a labelled evaluation set for clause detection and report consistency.
  • Add authenticated workspaces and human review states before considering sensitive use cases.