← zakagent.devCase study · Contract Intelligence
Grounded RAG · Citations · Next.js · Privacy by design

Contract Intelligence Assistant

A document-analysis tool — not legal advice — that answers questions grounded in the text and cites the exact clause every time.

Role: solo — architecture → deployLive app ↗Source ↗

Problem

Reading a contract you didn’t draft is slow, and the easy tools get it wrong.

Finding the parties, the dates, the payment terms and how the thing can be terminated means scanning the whole document by hand. Keyword search misses meaning — Ctrl-F for “terminate” won’t surface “either party may end this agreement on 30 days’ notice.” And a generic chatbot will answer confidently from training priors, with no way to trace a claim back to the text — exactly the wrong behaviour when the words are what matter.

Approach

Reuse the pipeline; build only what’s genuinely new.

The retrieval half was a solved problem — the RAG recipe from the lead-capture system. So the work concentrated on the three things that were actually different.

  • Reused: the grounded-RAG coreVoyage embeddings, a cosine-similarity retrieval pass, and forced tool-use for reliable structured output — lifted from the flagship system, so the trustworthy part was hardened on day one.
  • New: parsing & citation mappingClause-aware chunking that tracks each span’s page and character offsets, so a citation can highlight the precise phrase in the source — not a vague block.
  • New: grounded, refusing promptsClaude summarises and flags clauses “worth reviewing,” and answers only from the retrieved text — phrased as “the document states…,” never “you should…,” and declining when the text doesn’t support an answer.
  • New: privacy by designPeople paste real contracts, so nothing is persisted server-side. Parsing and retrieval run per request; the index lives only in the browser tab. A public rate limit protects the free endpoints — counters only, never content.

A single shared zod contract ties the boundaries together; every AI key stays on the server; two Claude models split the work — a stronger one for the summary and flags, a faster one for grounded Q&A.

Result

Every answer traces to a clause; unsupported questions get a refusal, not a hallucination.

Click a flag or a citation and the exact phrase highlights in the document. Ask something the contract doesn’t cover and the tool says so rather than inventing an answer — the behaviour that separates grounded retrieval from a generic chatbot. And because the document never lands on the server, the privacy story is real, not a promise.

What it demonstrates is RAG grounding and citation fidelity — not legal judgement, and no claim of legal accuracy. The efficiency story is the point: a pattern extracted from one engagement became a second shipped product, with the new effort spent only where the problem was new. Verified green end to end — typecheck, 57 tests and build — and driven live against Claude and Voyage.

A demonstration project. It analyses documents and is explicitly not legal advice.

Work together

Want grounded AI — with citations and guardrails — built for your product?

A RAG integration, an architecture review, or a full build. Tell me the problem and the outcome you’re after.