Golf companion web app. TypeScript (Node 24 LTS, 22.14+ supported), SQLite via better-sqlite3, sharp for images. Runs in Docker.
| Path | Purpose |
|---|---|
server/ |
HTTP server, SQLite access, handicap/stats logic, scan-LLM client |
client/app.ts |
Browser app; server strips types in memory and serves it as /static/app.js (no build step) |
templates/ |
index.html + static assets |
scripts/ |
sync.sh (deploy to NAS), ocr-cli.ts (scan one image from the shell) |
test/ |
vitest: unit, route-contract snapshots, migrations; helpers/server.ts boots the real app on a temp DB |
Dockerfile, docker-compose.yml |
Multi-stage image; data in named volume galf-data (DATA_PATH=/data) |
npm ci && npm run build # compile server to dist/ (client has no build step)
npm run dev # run from source
npm run check # Biome lint + format
npm run typecheck # server, tests, client
npm test # vitest
# all four must pass before a commit; CI runs the sameDev: 5003. Prod (NAS atabey): 5002. The split is deliberate. scripts/sync.sh stages the prod compose on sync (port 5002; live DB stays in the named volume galf-data); do not change the repo defaults.
scripts/sync.sh (dry-run by default, --apply to write). It never touches data/, *.db, .env. See README, "Deploying to the NAS".
- Round stored/displayed numbers with
roundTo(server/num.ts, ties to even), notMath.round/toFixed: every existing handicap and stat was computed with that rule, andtest/handicap.test.tsfails if a value shifts. - The database schema is unchanged since the pre-TypeScript version; keep upgrades additive.
test/__snapshots__/db.test.ts.snappins the DDL. - Naming: data fields are snake_case in the DB, API JSON and client (
course_name,hole_hcp); functions and variables are camelCase. Drill objects (stored as a JSON blob) use camelCase keys (resultType,resultLabel): a documented exception, not a pattern to copy. Don't rename fields; translate at one seam. - API responses are pinned by
test/routes.*.test.tssnapshots. A changed snapshot is a contract change: make it deliberately, in its own commit. client/app.tsis a classic script: its functions are globals because markup calls them from inlineonclick=strings. A top-levelletthat an inline handler assigns (e.g.statsTab) must staylet, even if the linter saysconst.