Contract-review RAG platform
BriefPilot
Contract review that cites the exact clause, reconciles amendments and grades every contract against your playbook.
- RAG
- FastAPI
- pgvector
- Claude + GPT-4o
- Stripe

Overview
BriefPilot is a full-stack document intelligence platform for contract analysis. A FastAPI backend runs a RAG pipeline — PDF/OCR ingestion, legal-aware chunking, pgvector embeddings — and streams LLM answers that cite their source clauses. On top sit a multi-document reconciliation engine, a batch liability auditor and a playbook checker.
How it works
- 1Upload PDF / scan
- 2OCR + legal chunking
- 3Embed → pgvector
- 4Retrieve clauses
- 5Claude / GPT-4o
- 6Cited answer (SSE)
What I built
End-to-end RAG pipeline
PDF extraction with OCR fallback, chunking on Section / Article / Clause delimiters, embeddings in Postgres + pgvector, token-streamed answers with clause-level citations.
Reconciliation engine
Pydantic-validated structured output decides which clause governs across a base agreement, amendments and riders. Every superseded clause is logged and explained.
Multi-model routing
Claude and GPT-4o with automatic failover, plus a semantic query cache (cosine ≥ 0.94) that cuts repeat inference cost.
Playbook checker
Users save their standard negotiating positions; each incoming contract is graded per rule with quoted evidence and severity-based verdicts.
Batch liability auditor
Risk audits across many contracts at once, with branded PDF audit certificates produced by a CSS paged-media print engine.
Billing, auth, tracing
Stripe subscriptions with signature-verified webhooks and a reconciliation path, Supabase Auth with Google/GitLab OAuth and RLS, and a custom span-level request tracer.
Engineering decisions
- Chunk on legal structure, not character count, so a retrieved chunk is a whole clause a lawyer would recognise.
- Use schema-validated structured output for reconciliation so the result can be audited, not just read.
- Cache by meaning, not by string: a 0.94 cosine threshold catches rephrased repeat questions without serving wrong answers.
- Treat Stripe webhooks as unreliable and reconcile against Stripe on login, so a missed event never strands a paying user.
Stack
- Frontend
- React 18, Vite, Tailwind CSS
- Backend
- Python 3.11, FastAPI, Uvicorn
- AI / LLM
- Claude, GPT-4o, text-embedding-3-small, LangChain (LCEL), Pydantic v2
- Documents
- Tesseract OCR, pdfplumber, PyPDF2, python-docx
- Data
- PostgreSQL + pgvector, SQLAlchemy, Alembic
- Platform
- Supabase Auth (JWT, RLS), SSE streaming, Stripe, n8n
Need something like this?
I can build a version of this for your product, your data and your stack.
Start a project