Skip to content

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).

Terminal window
git clone git@gitlab.com:littlebigco/legal-text-engine.git
cd legal-text-engine/worker && bun install
cd ../admin && bun install

Worker needs a .dev.vars file with ADMIN_TOKEN=<any value for local dev>.

Terminal window
cd worker
bun run db:apply # local D1
bun run db:apply:remote # remote D1
wrangler d1 execute legal-text-engine --local --file=migrations/schema-v2.sql
wrangler d1 execute legal-text-engine --remote --file=migrations/schema-v2.sql

Migrations are numbered flat files (schema.sql, schema-v2.sql, …), applied in order — not the wrangler d1 migrations tracked-migration system.

Terminal window
cd worker && bun run dev # http://localhost:8787
cd admin && bun run dev # http://localhost:5173
Terminal window
cd worker && bun run deploy # -> *.workers.dev
cd admin && bun run build && wrangler pages deploy dist \
--project-name legal-text-engine-admin
Terminal window
LTE_ADMIN_TOKEN=<token> bun scripts/drift-check.ts

Diffs 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.

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.