Legal Agreement AI

Architecture

One codebase, two deployment targets. The free demo and the production platform run the same application image logic, the same SQL migrations and the same drafting engine; only the infrastructure adapters change. Details and decision records: docs/architecture.md.

Production architecture diagram

This demo (free tier)

AppFastAPI on Vercel (Python 3.12, Fluid Compute), region Singapore
Workflow state + auditSupabase Postgres 17 (ap-southeast-1): api_* SQL functions, RLS, hash-chained audit
Clause searchSupabase Edge Function: gte-small embeddings + hybrid full-text / pgvector search (RRF)
Draftingrules mode: rules + A* clause assembly, no LLM cost
DeliveryGitHub Actions (tests, Postgres integration tests, eval gate) → Vercel deploys
SecretsNone in the app: only the publishable key; writes go through checked SQL functions

Production (Kubernetes)

AppAPI pods (gunicorn + uvicorn), HPA, PDB, NetworkPolicies, Entra ID OIDC at the ingress
WorkersQueue workers claim drafting jobs from Postgres (SKIP LOCKED), autoscaled on queue depth
DataManaged PostgreSQL + pgvector (same migrations), PITR backups, WORM export of the audit chain
ModelsTEI (gte-small) for embeddings; LLM via LiteLLM gateway (Azure OpenAI Data Zone APAC or self-hosted vLLM)
ObservabilityOpenTelemetry → Prometheus/Grafana; Langfuse for LLM traces; structured JSON logs
DeliveryHelm chart, Terraform (Azure), staged releases gated by the scoreboard