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.
This demo (free tier)
| App | FastAPI on Vercel (Python 3.12, Fluid Compute), region Singapore |
| Workflow state + audit | Supabase Postgres 17 (ap-southeast-1): api_* SQL functions, RLS, hash-chained audit |
| Clause search | Supabase Edge Function: gte-small embeddings + hybrid full-text / pgvector search (RRF) |
| Drafting | rules mode: rules + A* clause assembly, no LLM cost |
| Delivery | GitHub Actions (tests, Postgres integration tests, eval gate) → Vercel deploys |
| Secrets | None in the app: only the publishable key; writes go through checked SQL functions |
Production (Kubernetes)
| App | API pods (gunicorn + uvicorn), HPA, PDB, NetworkPolicies, Entra ID OIDC at the ingress |
| Workers | Queue workers claim drafting jobs from Postgres (SKIP LOCKED), autoscaled on queue depth |
| Data | Managed PostgreSQL + pgvector (same migrations), PITR backups, WORM export of the audit chain |
| Models | TEI (gte-small) for embeddings; LLM via LiteLLM gateway (Azure OpenAI Data Zone APAC or self-hosted vLLM) |
| Observability | OpenTelemetry → Prometheus/Grafana; Langfuse for LLM traces; structured JSON logs |
| Delivery | Helm chart, Terraform (Azure), staged releases gated by the scoreboard |