Running it locally

Optional: DVLA vehicle lookup

The Look up vehicle button needs the DVLA key. It is never committed; put it in the environment for the dev server, or in a Worker secret in production:

DVLA_API_KEY=... bun run dev        # dev middleware serves POST /api/vehicle
wrangler secret put DVLA_API_KEY    # production: the Worker reads it from here

Without a key the endpoint answers 503 and the button says the lookup is not set up. wrangler dev serves the same handler as production, if you want to test the Worker itself.

Prerequisites

  • Bun 1.4.2 or newer. The lockfile is bun.lock; use Bun rather than npm.
  • A modern browser with MediaRecorder, WebAssembly, getUserMedia and Web Workers.
  • Folder saving uses the File System Access API and therefore needs Chrome/Edge plus HTTPS (or localhost). Other browsers keep clips in IndexedDB and offer a download from the clip player.
  • Timeline uses OpenStreetMap tiles and needs a network connection; the route and markers still render without tiles.
  • For the camera, a secure context: http://localhost and http://127.0.0.1 work; a plain HTTP LAN address does not. Use a tunnel or HTTPS for testing on a phone.

Commands

bun install
bun run dev

Open http://localhost:4321 and the app at http://localhost:4321/app.

bun run build      # static build into dist/ (includes ~13 MB of models and the WASM runtime)
bun run preview    # serve the build locally
bun run check      # Astro's type check
bun run lint       # oxlint
bun test           # unit tests
bun run test:e2e   # Playwright, after `bunx playwright install`

bun run verify runs lint, the test type check, the unit tests, the Astro check and the build. It does not start a camera; the e2e suite covers the memory and chrome.

Models and runtime

The Nano pair is committed so the app works offline and the deploy has no model download step:

  • public/models/yolo26n_plate_640.onnx — 9.8 MB
  • public/models/plate_ocr_cct_xs_v2.onnx — 3.3 MB
  • public/models/plate_config_v2.json — alphabet, slots, regions and the detector’s input size and output layout

public/models/plate_ocr_cct_s_v2.onnx is kept for the benchmark harness and the /benchmarks page. The app reads with CCT-XS and never requests it.

Vite bundles the onnxruntime-web glue and emits the 15 MB processor runtime into _astro/. Everything comes from the same origin; there is no CDN.

onnxruntime-web runs inference in a proxy worker. Multi-threaded WASM needs SharedArrayBuffer, which needs a cross-origin isolated page, so the dev server and public/_headers send Cross-Origin-Opener-Policy: same-origin and Cross-Origin-Embedder-Policy: require-corp. A host that cannot send them still gets the worker, on a single thread.

To test with a screen instead of a camera, open Settings → Camera and recording → Use screen share and choose a tab/window. This runs the same pipeline as the camera.

To test with a photo instead of a camera, open Settings → Camera and recording → Test with a photo. This runs the exact same detector and OCR path on an image.

Content and settings

The site’s name, URL, repository and licence are one record in src/content/site/settings.json. The documentation is Markdown in docs/; frontmatter needs a title, a 40–200 character description, an ISO updated date and an order.

The sections are drivers, evidence, developers and other; other/ documents become the site-root notices (/privacy, /terms).

Icons

bun run icons regenerates the PNG favicons from public/icons/brand-mark.svg and public/icons/brand-maskable.svg. The manifest at public/manifest.webmanifest is hand-authored and is not overwritten.

Service worker

src/pages/sw.js.ts writes /sw.js at build time with the build version. It precaches the app shell and fetches the _astro chunks named by the two entry pages. The model and runtime files are not precached; they are cached by the browser (and by the worker after first use) so a scan does not re-download them. The pair is about 13 MB.

Deploying

wrangler.jsonc describes a static-assets Worker named sighted-app with dist/ as its directory.

bun run build
bunx wrangler deploy

The camera needs the deployed origin to be HTTPS. The Worker serves the static files and the DVLA lookup. If you set PUBLIC_MODEL_BASE to another origin, that origin must be added to connect-src in public/_headers.

Version

scripts/version.ts reads package.json and appends the short commit when one is available: v0.1.0+abc1234. Astro exposes it as __BUILD_VERSION__, which the service worker embeds.