A self-hosted mobile golf companion that lives on your iPhone. Log rounds, track your official WHS/USGA Handicap Index, analyze your game, and manage your club bag — all from a web app you run on your own hardware.
- Handicap tracking — Calculates a WHS-style Handicap Index from the best differentials of your last 20 eligible rounds, with net double bogey per-hole caps (adjusted gross score) driven by each course's hole handicaps. Serious 18-hole rounds count, and front and back 9-hole rounds are paired into 18s (not the 2024 expected-score method). Shows a provisional estimate until three rounds count. PCC, caps and exceptional-score reduction aren't implemented. Simulator rounds are excluded unless you opt in under Settings.
- Round logging — Quick score entry (one number per hole) or detailed hole-by-hole entry with GIR, putts, club, and penalty tracking. A searchable course picker with a Recent list speeds setup. 9-hole rounds can be extended to 18 mid-round, and 18-hole rounds can be finished early as a 9.
- Fix it before you save — Review & Save is editable. Tap the header to change course, tee, date, holes, or round type; tap the scorecard to step back through holes. Entered scores survive the edit — holes are remapped by number, and swapping to a sibling course at the same facility matches nines by par (and yardage) so a shared nine keeps its scores. Holes the edit leaves blank are flagged on the review card and become a short guided fill-in; nothing saves with a silent gap.
- Simulator rounds — Tracked separately with their own personal best. Putts are auto-rolled in both entry modes: in Quick mode you enter strokes to green and Galf adds the putts, so sim rounds still feed GIR without polluting putting stats.
- Practice sessions — Adaptive drill templates built from your bag. Covers warm-up, putting, chipping, Wedge Matrix (calibrates partial carry distances per wedge), irons, and woods. Saving a session writes updated wedge distances back to your club bag automatically. Sessions saved to history.
- Stats — GIR %, scrambling, putts per round, penalty strokes (water / OB / unplayable, plus per-round average), and stroke leak analysis by hole position.
- Course library — Store hole pars, per-tee yardages, slope rating, and course rating. Multiple tee colors per course (names are normalized to Title Case so
redandRednever drift apart). - Scorecard scanning — Optional: photograph a scorecard and a local vision LLM (Ollama / llama.cpp / LM Studio — nothing leaves your network) fills the Add Course form with pars, yardages, tee ratings, and slopes. Can be switched off in Settings.
- Club bag — Track carry distances (and partial-wedge distances) per club; during detailed entry the app suggests the fewest-shots club sequence to reach the pin.
- Personal bests — Home screen shows best IRL and simulator scorecards on a single toggle card. A full 18 always outranks a 9-hole round.
- Activity heatmap — 18-week calendar on the home screen showing days you played a round, practiced, or both.
- Settings — Two themes (Royal Green, Burgundy — each with light and dark variants), a toggle for whether sim rounds count toward the handicap, a home club (pinned first when logging), a hole-handicap row toggle, and an on/off switch for scorecard scanning. Stored server-side so they follow you across devices.
- Built-in manual — Full screen-by-screen reference with search, section chips, and prev/next paging, opened from Settings → Manual (renders this project's
MANUAL.mdlive).
- Docker (recommended), or Node.js 22.14+ (24 LTS recommended)
No accounts, no external services, no telemetry. The app runs fully on your own hardware. The only thing fetched from the internet is the marked markdown library (loaded from a CDN to render the in-app manual); the browser caches it, and the rest of the app works offline.
Create a .env file in the project root and set at minimum:
PORT=5003
docker compose up -dThe app starts on the port you configured (default 5003). Your data lives in a Docker volume (galf-data) and persists across restarts and container rebuilds.
On your Mac: http://localhost:5003
On your iPhone (same network): http://<your-mac-ip>:5003
To find your Mac's local IP: System Settings → Wi-Fi → Details.
npm ci
npm run buildScorecard scanning needs a vision LLM on another machine; see the scanning setup section below. Until one is set up in Settings → Scan LLM, Scan Card points you there; every other feature works.
Defaults work out of the box. To change them, set the variables below in the environment, or keep them in a .env file and start with node --env-file=.env dist/server/main.js (npm start itself does not read .env; only Docker Compose does).
The app reads PORT, DATA_PATH, and APP_NAME from environment variables.
npm startFor development, npm run dev runs the server straight from TypeScript. There is no browser build step: the server serves client/app.ts with its types stripped.
The startup banner prints the local and network URLs.
- Connect iPhone and Mac to the same Wi-Fi network.
- Open Safari on iPhone, navigate to
http://<mac-ip>:<port>. - Tap the Share button → Add to Home Screen for an app-like icon.
For permanent access without needing your Mac's IP, set up a local reverse proxy (e.g. nginx or Caddy) with a fixed hostname.
On first launch the app creates an empty SQLite database at DATA_PATH/galf.db. No seed data is loaded. Add your first course in the Courses tab, then log a round.
Upgrading an existing database is automatic: on startup the app adds any missing columns (e.g. the settings column on user_prefs) and normalizes stored tee color names to Title Case. No manual migration step.
Your entire game history lives in a single file: data/galf.db (or the path set by DATA_PATH).
Docker volume backup:
docker run --rm -v galf-data:/data -v $(pwd):/backup alpine \
tar czf /backup/galf-backup-$(date +%Y%m%d).tar.gz /dataDirect path backup:
cp data/galf.db galf-backup-$(date +%Y%m%d).dbTo restore, replace galf.db with your backup and restart the app.
All config is via environment variables (Docker Compose also reads them from .env):
| Variable | Default | Description |
|---|---|---|
PORT |
5003 |
Port the app listens on |
DATA_PATH |
./data |
Directory for galf.db |
APP_NAME |
Galf |
Name shown in startup banner |
OCR_LLM_KEEP_ALIVE |
0 |
Ollama native only: how long the model stays in RAM after a scan |
OCR_LLM_TIMEOUT |
180 |
Scan request timeout in seconds |
The scan engine does not run on the box hosting Galf — the app sends the photo to a vision LLM on another machine. Galf itself runs happily on a 1 GB ARM NAS (e.g. Synology DS124), which cannot fit any vision model worth using.
Scanning has no default server. In the app, open Settings → Scan LLM and enter:
- Base URL — an OpenAI-compatible endpoint, e.g.
http://<llm-host>:4000/v1(vLLM, LiteLLM, llama.cpp, LM Studio), or an Ollama nativehttp://<host>:11434/api/chat - Model — a vision-capable model served there
- API Key — optional bearer token
Then tap Test Connection. The settings are saved only when the test passes (server reachable and the model listed). The API key is stored server-side and never sent back to the browser. Until a test passes, Scan Card sends you to Settings instead of scanning.
The Galf container must be able to reach that host. Over Tailscale, if Docker can't resolve a MagicDNS name, use the machine's Tailscale IP.
For ad-hoc testing outside the app: OCR_LLM_URL=… OCR_LLM_MODEL=… npx tsx scripts/ocr-cli.ts card.jpg.
Scanning fills only the Add/Edit Course fields you have not filled yourself — anything you typed before scanning is kept. If the LLM server is unreachable, Scan Card reports it and every other feature keeps working.
Galf was rewritten from Python/Flask to TypeScript/Node with identical behaviour and the same database file — no export, import or conversion. Point the new container at the same galf-data volume and start it.
- On its first start the TypeScript server copies the existing database to
galf.db.bak-pre-tsnext to it (only if that file does not exist yet). - The schema is unchanged, so an old Python image (or a checkout from before the migration, in git history) can be started on the same volume again (rollback). The stats cache rebuilds itself either way.
- Take your own backup first anyway (see Backing Up Your Data).
Copies source only (server/, client/, templates/, scripts/, package files, Dockerfile, compose, docs) to /Volumes/docker/Galf; the Docker image builds from it. It never touches data/, *.db, *.sqlite*, .env, instance/, uploads/.
scripts/sync.sh # dry-run (default): lists changes, warns, writes nothing
scripts/sync.sh --apply # backup, move old Python files, sync, verify data unchanged
scripts/sync.sh --apply --restart # then rebuild on the NAS over ssh (needs GALF_NAS_SSH; asks first)- Refuses if
/Volumes/dockeris unmounted or the destination is not/Volumes/docker/Galf.--applyrefuses on a dirty git tree unless--allow-dirty. - Before writing: previous code state saved to
Galf/.sync-backups/<timestamp>/(code only, never the DB). Old Python files go toGalf/legacy-python/<timestamp>/(moved, not deleted). - After writing: checksums of everything in
data/and every DB file are compared with the pre-sync values. - Only
server/,client/,scripts/have stale files pruned; nothing else is deleted. - Port: prod stays on
5002; the repo default is5003(dev). The script rewrites the compose port to 5002 when syncing, so the repo file never changes. - First deploy: the new
docker-compose.ymlreplaces the old one (the old:/appbind mount would hide the built app). The script also syncs.gitignoreandAGENTS.md(the TypeScript versions). The NAS.gitis never modified. - Data: prod data lives in the docker named volume
galf-data(NOTGalf/data/galf.db, a stale May 2026 copy). The synced prod compose keeps that volume. Back the volume up (see above) before rebuilding. The script also copiesGalf/data/to~/galf-backups/<ts>/before every--apply. - Restart:
scripts/sync.sh --apply --restartasks y/N, then runscd /volume1/docker/Galf && sudo /usr/local/bin/docker compose up -d --buildoverssh -t josealma@atabey. ssh (and sudo) prompt for the password; nothing is stored. Override withGALF_NAS_SSH/GALF_NAS_DOCKER. - Rollback:
tar -xzf .sync-backups/<ts>/code-before.tgz -C /Volumes/docker/Galf, move files back fromlegacy-python/<ts>/.
server/ HTTP server, SQLite access, handicap/stats logic, scan-LLM client
client/ app.ts — the browser app (served as /static/app.js, types stripped at request time)
templates/ index.html and static assets (css, icons)
scripts/ sync.sh (deploy to the NAS), ocr-cli.ts (scan one image from the shell)
test/ vitest: unit, route-contract and migration tests
docs/ design notes
| Command | What it does |
|---|---|
npm run dev |
Run the server from source (no build step) |
npm run build |
Compile the server to dist/ (tests excluded) |
npm run check |
Lint and format check (Biome); npx biome check --write . fixes what it can |
npm run typecheck |
Type-check server, tests and client |
npm test |
Unit tests, HTTP route contract snapshots, migrations (rounding and handicap math against frozen expected values) |
The server strips TypeScript types from client/app.ts in memory and serves the result as /static/app.js (no build step, no bundler, no reformatting; types become whitespace so line/column positions match the source). Edit client/app.ts and reload the page. The browser app is a classic script: its functions are globals because the markup calls them from onclick= attributes.
Numbers the app stores or shows are rounded with roundTo (server/num.ts): ties go to the even digit, on the exact binary value. Every existing handicap and stat was computed that way, so don't swap in Math.round/toFixed — handicap values can shift by 0.1 and test/handicap.test.ts will fail.