# Hammurabi

An AI legal-analysis SaaS for Israeli lawyers, in Hebrew and English. I took it from first commit to production in about 3 months, then grew it into a paid product.

- Client: Hammurabi
- Role: Founding & lead engineer
- Team: Solo for 10 months, then a small team
- Period: 2024 – 2026
- Stack: TypeScript, Next.js, tRPC, MongoDB, Redis, Pinecone, Voyage AI, Python + FastAPI, TruLens, Stripe

| Result | Baseline | Now | Change |
| --- | --- | --- | --- |
| From first commit to production | – | ~3 months | Then paid tiers |
| Built solo before the team joined | – | 10 months | Then led |
| Legal AI tools on one framework | – | ~12 | Shipped |
| Retrieval strategies compared in TruLens | – | 4 | Best shipped |

## Context

Hammurabi is an AI legal-analysis SaaS for Israeli lawyers, in Hebrew and English. Lawyers upload pleadings, judgments and case files, chat with them, and run AI tools that analyse a pleading against a profile of the assigned judge. It sells on subscription tiers with credits.

The client, an Israeli founder, wrote the requirements. I turned them into architecture and code.

## My role

Founding and lead engineer for the whole engagement, April 2024 to early 2026. I built it solo for the first 10 months, then led a small team through a PR-based workflow, and stayed the #1 contributor across ~2 years.

## The problem

- **Retrieval needs context.** A legal answer depends on the text around the matching passage, in Hebrew and in English.
- **Hebrew everywhere.** Right-to-left UI, Hebrew prompts, and OCR for scanned documents.
- **A growing tool list.** Each new AI tool needed pricing, plan gating, background execution and a downloadable report.

## What I built

Documents go through OCR and chunking, then Voyage embeddings into Pinecone. Retrieval feeds the LLM layer, and results come back as chat answers or tool reports.

- **Platform.** Next.js, tRPC, MongoDB and Redis, with single-seat sessions enforced in Redis, an admin console, and a case-management layer.
- **Custom RAG retriever.** I first ran a **TruLens** evaluation harness comparing naive RAG, sentence-window and auto-merging retrieval on Hebrew and English legal text. Then I designed a **sentence-window + linked-chunk** retriever: each chunk stores its neighbours' ids, so after vector search and Voyage reranking the context is rebuilt around each hit. A query classifier routes simple, file-specific and contextual questions differently.
- **AI tools framework.** Each tool declares its credit price, minimum plan, background job and report format (HTML, DOCX or PDF). I shipped ~12 legal tools on it, including argument analysis, contradiction detection and success-probability scoring.
- **Judge profiling.** Profiles built from a judge's past rulings, with scrapers that fetch missing rulings. Python FastAPI services, built with a teammate, run the heavier analysis with Pydantic structured outputs.
- **LLM layer and billing.** One factory over Claude, GPT and Gemini, with admin model switching and editable prompts. Stripe subscriptions and credits.
- **Word add-in and v2.** I led a Microsoft Word add-in that brings suggestions into the document as accept-or-reject changes, and architected the v2 rebuild on Convex, WorkOS and Mastra.

## Results

- **In production about 3 months after the first commit**, then improved continuously as a paid product; the first 10 months built solo.
- **~12 legal AI tools** on one framework: a new tool became a config entry plus a handler.
- **A retriever chosen by evaluation** against three baselines, not by intuition.
- **Runtime Hebrew/English switching** across 1,195+ translated call sites without rewriting them.

## What I'd do differently

- **Evaluate retrieval from the first version.** RAG v1 shipped in spring 2024; the TruLens harness came that November. The harness led to the better retriever, so I'd build it alongside v1.
- **Settle billing early.** Billing moved from PayPal to WooCommerce to Stripe, and each move was real work. I'd push for the long-term provider before the first paying user.
- **Design for organisations from the start.** v1 was built around individual accounts. Multi-tenant organisations arrived with the v2 rebuild, when they could have been a v1 data-model decision.

Contact: arslanjs.dev@gmail.com · https://arslanjs.dev
