Q&A
Straight answers about UangCounsel itself: what's real, what's precomputed, how the pipeline works, and what happens to your data.
The project
›What is UangCounsel?
An AI contract-review tool built as a portfolio piece: upload a text-based PDF contract and get back clause-level risk flags, each pointing at the exact highlighted text that triggered it, plus a one-sentence business explanation and a negotiation ask per clause.
›Why did you build it?
As the third piece of a showcase for uang.ai ("The AI Factory"): UangLite proves an agent can safely operate a business app, UangFactory proves a website can prove instead of tell, and UangCounsel proves the same design language works on unstructured documents — one of uang.ai's own case-study verticals (legal).
›Is this affiliated with uang.ai?
No. Independent portfolio work by Rico — not affiliated with or endorsed by uang.ai. It is inspired by their positioning: business understanding + engineering + AI expertise.
›Is this legal advice?
No. The analysis is AI-assisted and directional. It is designed to tell you where to look and what to ask, not to replace a lawyer. Every output says so.
Real vs. precomputed
›Is the analysis real AI?
Yes. Uploaded PDFs run live through an LLM pipeline (any OpenAI-compatible endpoint). The three sample contracts ship with precomputed analyses — produced by the exact same pipeline, then frozen so the demo opens instantly and costs nothing to run.
›How do I know the highlights aren't faked?
Every highlight is geometry, not a screenshot: the server locates the model's verbatim quote back in a character-level coordinate index of the PDF. If a quote can't be found — for instance because the model truncated it — the clause card says 'quote not found' instead of pretending.
›What happens without an API key?
The samples still work fully (precomputed), and uploads return a clear 'LLM endpoint not configured' message instead of a broken screen. Graceful degradation is a design principle here, not an afterthought.
›Can the model hallucinate?
It can hallucinate a quote — that's exactly why the locate step exists. The pipeline only displays a quote it can find verbatim in the document; everything else is either repaired (one retry) or labeled as not found. The 'why' and 'suggestion' fields are model judgment and marked as directional.
How it works
›How does the highlighting work, technically?
pdf.js extracts every character with its page position. That builds a coordinate index; the model's quote is matched back to it (case-insensitive, whitespace-tolerant, with an ellipsis-fragment fallback) and merged into one rectangle per visual line. The viewer renders the PDF on canvas and absolutely positions colored overlays at those coordinates.
›What keeps the LLM output valid?
A strict JSON shape is spelled out in the prompt (OpenAI-compatible endpoints often run without hard schema enforcement), output is validated with zod with lenient normalization (e.g. 'High' → 'high'), and a failed attempt gets exactly one repair round-trip before falling back to a clear error.
›What are the limits?
Text-based PDFs only — scanned documents have no extractable text and are rejected with an explanation. Max 8 MB and 40 pages. Multi-column layouts can stress the line-merging heuristics. Rate-limited to 10 analyses per minute per IP.
Privacy & data
›Do you store my uploaded contracts?
No. Uploads are analyzed in memory and discarded. There is no database in this project — nothing about your document persists after the response is sent.
›What does the LLM provider see?
The extracted text of the document you upload is sent to the configured LLM endpoint to be analyzed. That's inherent to any LLM review. For sensitive contracts, run your own instance — the whole pipeline works self-hosted with a local model endpoint.
Stack & meta
›What is it built with?
Next.js 16 (App Router) · React 19 · Tailwind CSS 4 · TypeScript · AI SDK with any OpenAI-compatible endpoint · pdf.js for parsing and rendering · Vitest for unit tests · Playwright for end-to-end tests. No database by design.
›How was it tested?
Unit tests cover the geometry layer (quote location, fragment fallback) and output validation. Playwright end-to-end tests cover the full user flow: opening a sample, watching highlights render, clicking a clause to jump to its source text, theme switching, and the Q&A page.
›Where does dark/light mode come from?
A hand-rolled token system (CSS custom properties + Tailwind 4), persisted per browser, following prefers-color-scheme on first visit. No UI library needed.
›Can I run my own instance?
Yes — it's open source. Clone the repo, optionally set LLM_BASE_URL / LLM_API_KEY / LLM_MODEL as environment variables (any OpenAI-compatible endpoint works, including a local one), and deploy. Everything else works with zero configuration.
Something the Q&A doesn't cover? Try the reviewer and see for yourself.