Skip to main content
Back to Projects

Ratify: Alcohol Shipping Compliance Engine

A personal project: a compliance engine that tells alcohol producers where they can legally ship across all 50 states and DC, and cites the statute or refuses to answer.

2026

FastAPI
Next.js
Supabase
Anthropic Claude
Citations API
Railway
Vercel
  • Wine, beer and spirits shipping covered in all 51 US jurisdictions (50 states + DC) through 753 provisions of state law
  • Spot check against independently located legal sources: 37 of 37 sampled high-confidence answers matched the law, with zero made-up citations
  • Every answer carries its legal citation and a rating of how sure the engine is, or the engine refuses to answer
  • Recorded test cases for the wine rules of all 51 jurisdictions check every cited span against a saved copy of its source page on every build
Ratify: Alcohol Shipping Compliance Engine title card

System Architecture

Ratify: Alcohol Shipping Compliance Engine system architecture diagramOpen the diagram full size

Problem

Selling beverage alcohol in the US means complying with the regulatory regimes of 51 US jurisdictions (50 states plus DC), two distribution channels (shipping direct to consumers, and three-tier wholesale through distributors and retailers), and constant rule changes. The source text is scattered across 50+ government sites, so producers often fall back to spreadsheets and manual research.

Approach

I built the compliance and tax engine as a stand-alone, deterministic rules system, with AI next to it for the unstructured work: natural-language compliance questions, regulatory document extraction, expansion planning and audit report synthesis. The AI reads each law in two passes, first finding the exact sentence and then pulling the rule from it, so every rule it extracts carries a word-for-word quote of its source.

Architecture

FastAPI on Railway handles the compliance engine, background workers, and integrations (Commerce7, Offset Commerce) without Vercel's 800-second function ceiling. Next.js 16 on Vercel runs the dashboard with Server Components. Supabase Postgres holds each workspace's data behind Row-Level Security, so an account can only ever read its own rows, and the assistant pulls matching rule rows with plain SQL and hands them to the Citations API; vector search waits until the corpus outgrows it. Ratify is Anthropic-only for AI inference, because cite-or-refuse depends on the Citations API, which is Anthropic-specific: daily per-workspace and global caps on assistant spend are checked before each paid call, and when a Claude Sonnet 4.6 call fails with a server error, the assistant retries once on Claude Haiku 4.5. Rules are stored by jurisdiction type rather than by state, so adding a county or a city later means adding rows, not redesigning the database.

More Results

  • 788+ test files, 130+ database migrations and 30+ automated build and test workflows
  • Deployed in production: the API on Railway, the dashboard on Vercel and the database on Supabase

Lessons Learned

When a compliance answer has to hold up when someone checks it, AI belongs next to the rules, not inside them. Two-pass extraction with verbatim citations means every AI-extracted rule can be traced to the sentence it came from. Naming the rules table for jurisdictions rather than states cost nothing at the start and leaves room for county and city rules later.