Skip to content

Latest commit

 

History

History
41 lines (30 loc) · 2.5 KB

AGENTS.md

File metadata and controls

41 lines (30 loc) · 2.5 KB

AGENTS.md — Galf

Golf companion web app. TypeScript (Node 24 LTS, 22.14+ supported), SQLite via better-sqlite3, sharp for images. Runs in Docker.

Layout

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)

Commands

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 same

Ports

Dev: 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.

Deploy

scripts/sync.sh (dry-run by default, --apply to write). It never touches data/, *.db, .env. See README, "Deploying to the NAS".

Rules

  • Round stored/displayed numbers with roundTo (server/num.ts, ties to even), not Math.round/toFixed: every existing handicap and stat was computed with that rule, and test/handicap.test.ts fails if a value shifts.
  • The database schema is unchanged since the pre-TypeScript version; keep upgrades additive. test/__snapshots__/db.test.ts.snap pins 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.ts snapshots. A changed snapshot is a contract change: make it deliberately, in its own commit.
  • client/app.ts is a classic script: its functions are globals because markup calls them from inline onclick= strings. A top-level let that an inline handler assigns (e.g. statsTab) must stay let, even if the linter says const.