# renderer — the finished-game image-render sidecar

An internal-only Node service that rasterizes the finished-game export PNG. It runs the
**same** `ui/src/lib/gameimage.ts` the web project unit-tests — bundled verbatim at image
build time (`src/entry.ts` → esbuild → `dist/gameimage.mjs`) — on
[skia-canvas](https://github.com/samizdatco/skia-canvas), so the server render is
pixel-identical to the design the owner signed off in the browser.

## Interface

- `POST /render` — `{game, moves, alphabet, labels, dateLocale, hostname, scale?}` →
  `image/png`. `game`/`moves` are the ui-model shapes (`GameView` / `MoveRecord[]`);
  `alphabet` is the per-variant `(index, letter, value)` table tile values are drawn
  from; `labels` localizes the non-play moves (pass/exchange/resign/timeout);
  `hostname` + `dateLocale` feed the footer.
- `GET /healthz` — liveness (the compose healthcheck the backend's `depends_on` gates on).

The service draws and nothing else: authentication, the participant check and the signed
public download URL all live in the backend (`backend/internal/server/export.go`); the
network path is client → gateway `/dl/*` → backend → this sidecar.

## Development

```sh
pnpm install          # skia-canvas + esbuild MUST stay approved in pnpm-workspace.yaml
                      # (allowBuilds) or the native binary is silently never fetched
pnpm test             # bundles, then node --test against testdata/request.json
node src/server.mjs   # local run on :8090 (RENDERER_PORT overrides)
```

The runtime image (`renderer/Dockerfile`, `node:22-slim`) bakes in Liberation Sans (the
UI font stack's Linux face) and Noto Color Emoji (the scoresheet 🏆); skia-canvas picks
both up through fontconfig. The fixture `testdata/request.json` is a real 35-move
self-played Russian Scrabble game.
