No description
- Go 92.8%
- CSS 6.8%
- Dockerfile 0.2%
- Makefile 0.2%
| cmd/coach | ||
| internal | ||
| .dockerignore | ||
| .gitignore | ||
| compose.yaml | ||
| Dockerfile | ||
| go.mod | ||
| go.sum | ||
| Makefile | ||
| README.md | ||
Coach
Coach is a small single-binary Go web app for tracking calorie intake and body weight.
It is intentionally simple:
- log meals with calorie counts
- log weight entries
- view a chronological journal
- view a graph with cumulative calorie budget vs. actual intake
- overlay weight on the all-time graph
The app is server-rendered with Go templates, uses HTMX for UI interactions, and stores all data in a single SQLite file.
High-Level Shape
cmd/coach/- CLI entrypoint and
servecommand
- CLI entrypoint and
internal/service/- domain types, validation, journal assembly, chart generation
internal/database/- SQLite open/init, migrations, store implementation
internal/app/- HTTP handlers, request context parsing, view models, templates, static assets
internal/testutil/- shared test setup helpers
Runtime Model
- single process
- single SQLite database file
- no external services
- no frontend build step
- mobile-first SSR UI with HTMX-loaded modals
Optional private access gate:
- set
COACH_AUTH_TOKEN(or pass--auth-token) to require a one-field login - successful login sets a browser cookie used on later requests
The default local development flow uses:
./bin/coachfor the built binary./data/coach.sqlite3for runtime data
Request Flow
Most interactions follow the same shape:
- HTTP handler parses form input or query state
- service layer validates and applies domain rules
- database layer persists or loads SQLite state
- app layer rebuilds view models from persisted state
- templates render either a full page or HTMX fragment
The server remains the source of truth after every write.
UI Model
- pinned graph at the top of the screen
- scrollable journal below it
- journal header actions for adding meal and weight entries
- chart header settings action beside the mode switch
- modal forms for create/edit flows
- week and all-time graph modes
Meal and weight timestamps are intentionally normalized to the hour.
Development
make buildbuilds./bin/coachmake runbuilds and runs against./data/coach.sqlite3make testruns the test suite
Meal Summary API
The server also exposes a plain-text summary endpoint intended for LLM-friendly analysis:
GET /api/summary/meals- Optional query params:
start_date=YYYY-MM-DDend_date=YYYY-MM-DD
- If no query params are provided, all logged meal dates are included.
- If auth is enabled (
--auth-tokenorCOACH_AUTH_TOKEN),/api/*routes requireAuthorization: Bearer <token>.
Example:
curl -H "Authorization: Bearer example-password" \
"http://127.0.0.1:8080/api/summary/meals?start_date=2026-03-01&end_date=2026-03-31"
Notes For Developers
- templates and static files are embedded into the binary
- chart rendering is done server-side as SVG
- persisted timestamps are stored as Unix seconds in SQLite
- the database package implements the service-owned store interface
- tests are in-process and exercise the app without starting a real listener