Drop any contract. Understand it in minutes. Everything stays on your laptop.
A private, local-first AI that helps people understand agreements before they sign them. ThatContract explains every clause in plain language, flags what's worth noticing, extracts money and deadlines, finds things worth discussing, compares contracts, and answers your questions — all running 100% locally via Ollama. No cloud, no API keys, no subscriptions, no data ever leaving your computer.
Free local AI · No cloud · No accounts · No data leaves your device. Part of the Free AI. Real Problems. Every Sunday. series.
⚖️ Not a lawyer, not legal advice. ThatContract helps you understand a contract; it does not provide legal advice. For anything that needs legal certainty, consult a qualified legal professional.
Repo layout: the app lives in
frontend/(Next.js) andbackend/(FastAPI). The root-levelproject.md,design.md, andAPI_CONTRACT.mdare the build spec, design system, and the shared frontend↔backend contract.
- Why ThatContract
- Features
- Architecture
- Tech stack
- System requirements
- Quick start
- Manual setup
- Supported documents
- Configuration
- Project structure
- API overview
- How analysis works
- Privacy
- Safety & disclaimer
- Limitations
- Roadmap
- Troubleshooting
- License
- Author
Almost nobody reads contracts, and even fewer understand them. Offer letters, leases, NDAs, and vendor agreements are dense, jargon-heavy, and easy to sign without grasping what you've agreed to. The obvious shortcut — pasting the document into a cloud AI — means handing a private legal document to a third party.
ThatContract is the missing layer: it reads the contract on your own machine and explains it like a knowledgeable friend sitting beside you — what each clause means, why it exists, what to watch for, and what's worth discussing. A deterministic rule engine finds the clauses, risks, money, and dates; the local LLM explains them in plain English. The focus is understanding, confidence, and transparency — never replacing your lawyer.
- 🔒 100% local & private — no cloud, no API keys, no telemetry. Your documents never leave your computer.
- 🧩 Explain every clause — original text + plain English, why it exists, what it means, an example, the potential risk, what happens if ignored, and a negotiation idea.
- 🟢🟡🔴 Overall contract health — Looks Standard / Needs Attention / High Risk, with per-clause risk levels.
⚠️ Things you should notice — gentle, non-alarming flags for one-sided terms, unlimited liability, broad IP assignment, auto-renewal, hidden penalties, mandatory arbitration, and more.- 💸 Money extraction — salary, deposit, rent, EMI, penalties, refunds, taxes — with amount, currency, frequency, and clause reference.
- 📅 Deadline timeline — payment dates, notice periods, renewals, expiry, lock-ins, refund windows — as a clean visual timeline.
- 🧭 Missing-clause detection — what's normally expected for this contract type but absent.
- 🤝 Things worth discussing — collaborative negotiation prompts, never fear-based.
- 💬 Ask ThatContract — chat grounded in your actual clauses; it cites them and says clearly when info is absent.
- ⚖️ Compare two contracts — side-by-side across salary, notice, termination, IP, liability, renewal… with a reasoned recommendation.
- 🧠 Runs on what you have — auto-detects your installed Ollama models (Llama 3.x, Qwen, Mistral, …).
- 📤 Export — beautiful HTML, Markdown, or JSON reports.
- 🌗 Dark + light mode, premium minimal UI, smooth states.
Next.js frontend (:3000) ──HTTP /api──▶ FastAPI backend (:8000) ──▶ Ollama (:11434)
│
├─ Deterministic clause engine (regex + JSON pattern libraries)
├─ Document pipeline (PyMuPDF · pdfplumber · python-docx · optional OCR)
├─ SQLite (metadata) + JSON files (analysis, reports, chat)
└─ AI enrichment (Ollama, strict-JSON + repair + fallback)
The analysis pipeline:
upload ─▶ extract text ─▶ (OCR if needed) ─▶ detect contract type ─▶ split into clauses
─▶ deterministic clause engine ─▶ AI enrichment (best-effort) ─▶ risks · money · deadlines
─▶ missing clauses ─▶ assemble report
The deterministic engine runs with zero Ollama dependency — it classifies clauses, scores risk, and extracts money/dates from rules alone. The LLM then enriches each result with plain-English explanations, examples, and negotiation ideas. If Ollama is unavailable, the report still generates from the deterministic layer; the AI never replaces it.
| Layer | Technology |
|---|---|
| Frontend | Next.js 15 (App Router), React 19, TypeScript 5, Tailwind CSS v4 |
| Backend | Python 3.12, FastAPI, Pydantic v2, Uvicorn |
| Local LLM | Ollama (llama3.2 by default; any installed model, auto-detected) |
| Documents | PyMuPDF, pdfplumber, python-docx; optional OCR (pytesseract + Tesseract) |
| Storage | SQLite (metadata) + JSON files (analysis, reports, chat) — all local |
| Tooling | run.sh / run.bat one-command launcher; npm; venv |
ThatContract runs a real LLM locally, so the main cost is RAM and disk for the model — not a network connection.
- Node.js 18.18+ — https://nodejs.org
- Python 3.11–3.13 (avoid 3.14 for now — some PDF libraries lack wheels) — https://www.python.org
- Ollama — https://ollama.com/download
- OS — macOS, Linux, or Windows (WSL2 recommended on Windows)
- (Optional) Tesseract for OCR on scanned PDFs/images
| Resource | Minimum | Recommended |
|---|---|---|
| RAM | 8 GB | 16 GB+ (smoother with other apps open) |
| Disk | ~5 GB free | 10 GB+ (model ≈ 2–5 GB + deps) |
| CPU | Any modern 64-bit multi-core | Apple Silicon / recent x86 |
| GPU | Not required (CPU inference) | Any Ollama-supported GPU = much faster |
Note on speed: on a CPU-only machine, a full multi-clause contract can take 1–3 minutes to analyze, because each clause is enriched by the local model. A GPU or Apple Silicon makes this dramatically faster. The UI shows honest progress while it works.
./run.sh # macOS / Linuxrun.bat :: Windowsrun.sh checks Node + Python + Ollama, starts Ollama, creates the backend virtualenv and
installs dependencies, installs frontend dependencies, launches the backend on :8000 and
the frontend on :3000, and serves the app at http://localhost:3000. Press Ctrl+C to
stop both.
# 0) Start Ollama and pull a model (first run only)
ollama serve &
ollama pull llama3.2
# 1) Backend
cd backend
python3.12 -m venv .venv && source .venv/bin/activate
pip install -r requirements.txt
uvicorn app.main:app --host 127.0.0.1 --port 8000
# 2) Frontend (new terminal)
cd frontend
npm install
NEXT_PUBLIC_API_BASE=http://localhost:8000 npm run devThen open http://localhost:3000. No contract handy? Click View Demo to analyze a bundled sample (employment, NDA, rental, or freelance).
Contract types: Employment, Offer Letters, Rental Agreements, NDAs, Freelance Agreements, Vendor Agreements, Consulting Contracts, Insurance Policies, Loan Documents, Purchase Agreements, Terms & Conditions, Service Agreements, and general legal contracts.
File types: PDF, DOCX, TXT, images, and scanned PDFs (scanned files need optional OCR).
| Setting | Where | Default | Purpose |
|---|---|---|---|
| Default model | backend/app/config.py |
llama3.2 |
Preferred Ollama model (auto-falls back) |
OLLAMA_HOST |
environment | http://localhost:11434 |
Local Ollama URL |
MODEL |
environment (read by run.sh) |
llama3.2 |
Model to pull if none is installed |
THATCONTRACT_PORT |
environment | 8000 |
Backend port |
FRONTEND_PORT |
environment | 3000 |
Frontend port |
NEXT_PUBLIC_API_BASE |
frontend environment |
http://localhost:8000 |
Where the UI calls the backend |
The model is a preference: the backend uses it if installed, otherwise auto-detects the best installed model. The chosen model is shown on every report.
ThatContract/
├── frontend/ # Next.js App Router UI
│ ├── app/ # routes: / · /analyze · /report/[id] · /compare · /history
│ ├── components/ # Hero, FileDropzone, HealthBadge, ClauseExplorer, RiskList,
│ │ # MoneyTable, Timeline, MissingClauses, AskChat, CompareTable, …
│ ├── lib/ # api.ts (typed client), types.ts (contract), theme.ts
│ └── app.config.ts # branding
├── backend/ # FastAPI service (the analysis engine)
│ └── app/
│ ├── main.py # app factory, CORS, router wiring, health
│ ├── config.py # model default, paths, expected-clause maps
│ ├── schemas.py # Pydantic models (ContractReport, Clause, Risk, …)
│ ├── ollama_client.py # model detection/resolution + strict-JSON generate (repair + retry)
│ ├── prompts.py # all prompt templates (strict JSON)
│ ├── documents/ # extract.py · ocr.py (optional) · segment.py
│ ├── clause_engine/ # engine.py + patterns/*.json (18 deterministic libraries)
│ ├── analyzer.py # orchestrates the full pipeline
│ ├── chat.py · comparison.py · reporting.py · storage.py · demo.py
├── demo/ # sample contracts (employment, NDA, rental, freelance)
├── data/ # local-only runtime data (gitignored) — your documents stay here
├── API_CONTRACT.md # authoritative frontend↔backend contract
├── project.md / design.md # build spec + design system
├── run.sh / run.bat # one-command launchers
├── LICENSE # MIT
└── README.md
All endpoints are served by the backend at http://localhost:8000. Full shapes live in
API_CONTRACT.md; interactive docs at http://localhost:8000/docs.
| Method | Endpoint | Purpose |
|---|---|---|
| GET | /api/health |
Service health check |
| GET | /api/ollama |
Ollama status + installed models |
| POST | /api/analyze |
Analyze an uploaded contract → full report |
| GET | /api/contracts · /api/contracts/{id} |
List / fetch stored reports |
| DELETE | /api/contracts/{id} |
Delete one analysis |
| POST | /api/clause/explain |
Re-explain a clause (Simple / Story / Example / Bullets) |
| POST | /api/ask |
Ask a question grounded in the contract |
| POST | /api/compare |
Compare two contracts side by side |
| GET | /api/report/{id}?format=html|md|json |
Export a report |
| GET | /api/demo · POST /api/demo/{key}/analyze |
Bundled sample contracts |
| DELETE | /api/data |
Permanently wipe all local data |
- Extract text (PyMuPDF → pdfplumber fallback for PDFs; python-docx for DOCX; direct for TXT).
- OCR scanned pages if Tesseract is available (optional; degrades gracefully otherwise).
- Detect the contract type and segment the text into logical clauses.
- Deterministic clause engine — 18 JSON pattern libraries + regex classify each clause, score risk and confidence, and extract money and deadlines. No model needed.
- AI enrichment — the local LLM writes the plain-English explanation, example, negotiation idea, etc., for each clause (strict JSON, repaired and retried; falls back to deterministic text if Ollama is down).
- Assemble the report — health, counts, summary, risks, money, timeline, missing clauses, things to notice, things worth discussing — and store it locally.
ThatContract is local-only: no cloud calls, no telemetry, no external AI services. Uploaded
documents and all generated analysis live under data/ on your machine (gitignored). A
Delete Everything button permanently wipes that local data. The only network traffic is
to your own Ollama instance on localhost.
ThatContract is an educational tool to help you understand a contract. It is not a lawyer and does not provide legal advice. It can misread or miss things, especially in unusual or heavily customized agreements. Every report and chat answer carries a disclaimer, the AI is instructed to ground answers in the actual clauses and to say when information is absent, and the tone stays collaborative ("Things You Should Notice" / "Things Worth Discussing") rather than fear-based. For anything that needs legal certainty, consult a qualified legal professional.
- Quality of the plain-English explanations scales with the model —
llama3.2:3bis fast but basic; larger models (Qwen 2.5, Llama 3.1, Mistral) read clauses more accurately. - Scanned PDFs/images require optional OCR (Tesseract); without it, image-only pages are skipped.
- CPU-only analysis of a long contract takes a few minutes.
- The deterministic engine targets common clause patterns; very unusual drafting may be miscategorized — always verify anything important with a professional.
Version comparison · clause rewriting · contract drafting · jurisdiction packs · organization workspace · local RAG across many contracts · digital-signature integration · company-policy comparison · AI clause recommendations.
| Problem | Fix |
|---|---|
| "ThatContract needs Ollama running locally." | Start it: ollama serve |
| No model / model not found | ollama pull llama3.2 (or any model — the app auto-detects) |
| Analysis is slow | Normal on CPU (1–3 min for a full contract). Use a smaller model or a GPU. |
| Scanned PDF has no text | Install Tesseract + pip install pytesseract pillow for OCR |
pip install fails on Python 3.14 |
Use Python 3.11–3.13 (python3.12 -m venv .venv) |
| Port already in use | THATCONTRACT_PORT=8001 FRONTEND_PORT=3001 ./run.sh |
| Frontend can't reach backend | Confirm backend on :8000 and NEXT_PUBLIC_API_BASE |
Released under the MIT License — see LICENSE. Copyright © 2026 Krishna Rode.
Developed by Krishna Rode. Part of the Free AI. Real Problems. Every Sunday. series.