Getting Started — Legal Text Engine
Repo: git@gitlab.com:littlebigco/legal-text-engine.git (private). Two
independent apps: worker/ (Hono API on Cloudflare Workers) and admin/
(Vite/React on Cloudflare Pages).
Local setup
Section titled “Local setup”git clone git@gitlab.com:littlebigco/legal-text-engine.gitcd legal-text-engine/worker && bun installcd ../admin && bun installWorker needs a .dev.vars file with ADMIN_TOKEN=<any value for local dev>.
Schema and seed data
Section titled “Schema and seed data”cd workerbun run db:apply # local D1bun run db:apply:remote # remote D1wrangler d1 execute legal-text-engine --local --file=migrations/schema-v2.sqlwrangler d1 execute legal-text-engine --remote --file=migrations/schema-v2.sqlMigrations are numbered flat files (schema.sql, schema-v2.sql, …), applied
in order — not the wrangler d1 migrations tracked-migration system.
Running locally
Section titled “Running locally”cd worker && bun run dev # http://localhost:8787cd admin && bun run dev # http://localhost:5173Deploying
Section titled “Deploying”cd worker && bun run deploy # -> *.workers.devcd admin && bun run build && wrangler pages deploy dist \ --project-name legal-text-engine-adminDrift check
Section titled “Drift check”LTE_ADMIN_TOKEN=<token> bun scripts/drift-check.tsDiffs the hand-maintained KNOWN_INFRASTRUCTURE list in the script against
the real processors table, and checks for orphaned processor_id
references on activities. Not full auto-discovery — see the script’s header
comment for why.
Publish workflow
Section titled “Publish workflow”Every activity starts at draft. The publish gate blocks a business’s
publish until every activity for it is self-reviewed or lawyer-confirmed
— there is no override. POST /api/preview renders the full document with
draft activities included (each tagged with its status) and archives it to
R2 without touching the gate, for review before anything’s approved.