Ratify
Multi-tenant legal-tech SaaS that uses a multi-model AI council to review UAE contracts, flag risks against UAE law, and generate negotiation redlines.
What I did
Architected a 3-stage multi-model "LLM Council" pipeline (Claude Opus/Sonnet, Grok, Gemini via OpenRouter) that analyzes contracts in parallel, ranks findings by consensus, and synthesizes a 6-section legal report - with cost tracking, per-stage retries, and live streaming persisted to Postgres
Built a legal-domain RAG layer using Voyage AI voyage-law-2 embeddings + pgvector (HNSW, cosine) across four vector stores, with PII anonymization before embedding and graceful degradation when the vector DB is unavailable
Implemented document classification and a pre-flight quality gate (entropy/coherence checks + Haiku) that blocks unreadable input, detects locked government templates, and routes low-confidence docs to human review
Engineered structured LLM output with Zod schemas, JSON-repair fallbacks, bilingual (EN/AR) generation, and an AI redline generator producing tracked-change HTML/PDF amendments scoped to high-risk clauses
Shipped authentication end-to-end on NextAuth v5 - email/password, Google/Apple OAuth, account linking, and a 30-day reactivation flow - plus Stripe payments with a prepaid credits system using Serializable transactions
Integrated Shufti Pro KYC/KYB (face liveness, AML/PEP screening, signed webhooks) and migrated durable background processing to Inngest for long-running analysis
Built a design system of 50+ reusable React components documented in Storybook, used across customer, lawyer-reviewer, and admin portals spanning 90+ pages