Skip to content

Local development

  • Bun 1.4 or newer.
  • No Cloudflare account is needed for local work. Everything runs in wrangler dev --local with local D1, R2, KV and Queues.
Terminal window
bun install
bun run setup # creates workers/*/.dev.vars, migrates both local D1s, loads the seed and sample PDFs
bun run dev # builds the sites, then starts the five Workers
URL What
http://localhost:8787 The app (staff and /portal), with /api, /auth and /agents proxied
http://www.localhost:8787 The landing page
http://docs.localhost:8787 These docs
http://localhost:8788 cemco-api directly
http://localhost:8789 cemco-auth directly
http://localhost:8790/mcp cemco-mcp
http://localhost:8791 cemco-agents

*.localhost resolves to your machine in every current browser. For curl, send the host name: curl -H "Host: docs.localhost:8787" http://127.0.0.1:8787/.

Links between the sites are written with their production URLs (https://app.cemco.app/...); outside production cemco-web rewrites them to the local hosts, so clicking around works.

With ENVIRONMENT=development in workers/auth/.dev.vars (set by bun run setup, and only there):

Terminal window
curl -H "x-cemco-dev-user: cooper@cemcoinc.com" http://localhost:8787/api/v1/me
curl -X POST -H "x-cemco-dev-user: cooper@cemcoinc.com" -H "content-type: application/json" \
-d '{}' http://localhost:8787/api/v1/ops/reports.dashboard
Seed login Who
cooper@cemcoinc.com Staff, admin
maria@cemcoinc.com Staff, editor
jake@cemcoinc.com Staff, viewer
dana.whitfield@example.com Customer, Red River Ready Mix
luis.ortega@example.com Customer, Caprock Concrete Supply

Any other cemcoinc.com address signs in as a new viewer. Outside development these routes return 404 and the header is ignored.

The seed is written relative to 2026-12-06: 10 accounts, 14 orders across all nine stages (SO-2026-0032 and SO-2026-0033 are not valid and sit at Received), 17 machines (M300-2419 is down with ticket T-00041), tickets in every status, 61 parts (about 20 with stale 2020 prices, several below their reorder point), 6 parts orders, overdue tasks and a pending portal invite.

Command What it does
bun run dev:workers Start the Workers without rebuilding the sites
bun run dev:app Vite with hot reload on http://localhost:5173, proxying to 8787
bun run --filter @cemco/docs dev This site with hot reload on http://localhost:4322
bun run --filter @cemco/www dev The landing page on http://localhost:4321
bun run build Build views, app, www and docs into workers/web/public, then assemble
bun run typecheck / lint / test Checks for every package
bun run db:reset:local Wipe local state, migrate and seed again
bun run db:seed:build Regenerate packages/db/seed/seed.sql from packages/db/scripts/seed-data.ts

Workers AI needs a Cloudflare login even in local mode. To use the assistant and nameplate reading locally, set ANTHROPIC_API_KEY in workers/agents/.dev.vars and workers/api/.dev.vars. Without either, those features report not connected and everything else works.

bun run dev starts one wrangler dev --local per Worker; they find each other through wrangler’s dev registry. bun run dev:multi runs all five in one process, but only after wrangler login: wrangler does not pass --local to the second and later configs, so their AI binding asks for a Cloudflare session.