No description
  • Go 86%
  • HTML 9%
  • JavaScript 1.8%
  • CSS 1.7%
  • Shell 1.4%
  • Other 0.1%
Find a file
Rune Jensen 0e15dbee87
All checks were successful
ci/woodpecker/push/build Pipeline was successful
ci/woodpecker/push/docker Pipeline was successful
scan fix
2026-07-17 10:43:23 +00:00
.woodpecker Add web UI CI, docs and smoke test (WP5) 2026-07-13 03:36:16 +00:00
migrations Add product class UUIDs with printable, scannable QR labels 2026-07-13 17:12:13 +00:00
web scan fix 2026-07-17 10:43:23 +00:00
.env.example Add web UI foundation (WP0) 2026-07-12 12:39:52 +00:00
.gitignore Initial implementation of pantryapi 2026-07-11 17:54:12 +00:00
api.md Allow kind=consume in the by-EAN stock entry form 2026-07-17 10:30:18 +00:00
auth.go Initial implementation of pantryapi 2026-07-11 17:54:12 +00:00
auth_test.go Initial implementation of pantryapi 2026-07-11 17:54:12 +00:00
classes.go Add product class UUIDs with printable, scannable QR labels 2026-07-13 17:12:13 +00:00
docker-compose.yaml Add web UI foundation (WP0) 2026-07-12 12:39:52 +00:00
Dockerfile Initial implementation of pantryapi 2026-07-11 17:54:12 +00:00
Dockerfile.web Add web UI foundation (WP0) 2026-07-12 12:39:52 +00:00
eandb.go Initial implementation of pantryapi 2026-07-11 17:54:12 +00:00
go.mod Add product class UUIDs with printable, scannable QR labels 2026-07-13 17:12:13 +00:00
go.sum Add product class UUIDs with printable, scannable QR labels 2026-07-13 17:12:13 +00:00
groups.go Initial implementation of pantryapi 2026-07-11 17:54:12 +00:00
handlers.go Initial implementation of pantryapi 2026-07-11 17:54:12 +00:00
handlers_test.go Initial implementation of pantryapi 2026-07-11 17:54:12 +00:00
history_test.go Add internal EAN generation and per-class transaction history 2026-07-12 11:36:07 +00:00
internal_ean_test.go Add internal EAN generation and per-class transaction history 2026-07-12 11:36:07 +00:00
locations.go Initial implementation of pantryapi 2026-07-11 17:54:12 +00:00
main.go Add internal EAN generation and per-class transaction history 2026-07-12 11:36:07 +00:00
pagination_test.go Initial implementation of pantryapi 2026-07-11 17:54:12 +00:00
products.go Add internal EAN generation and per-class transaction history 2026-07-12 11:36:07 +00:00
README.md Document automatic database migrations in README 2026-07-14 18:45:14 +00:00
scan.go Initial implementation of pantryapi 2026-07-11 17:54:12 +00:00
scan_test.go Initial implementation of pantryapi 2026-07-11 17:54:12 +00:00
shopping.go Add minimum stock and shopping list endpoint 2026-07-11 18:52:33 +00:00
shopping_test.go Add minimum stock and shopping list endpoint 2026-07-11 18:52:33 +00:00
split.go Initial implementation of pantryapi 2026-07-11 17:54:12 +00:00
split_test.go Initial implementation of pantryapi 2026-07-11 17:54:12 +00:00
stock.go Allow kind=consume in the by-EAN stock entry form 2026-07-17 10:30:18 +00:00
stock_test.go Allow kind=consume in the by-EAN stock entry form 2026-07-17 10:30:18 +00:00
store.go Initial implementation of pantryapi 2026-07-11 17:54:12 +00:00
store_test.go Initial implementation of pantryapi 2026-07-11 17:54:12 +00:00
taxonomy_test.go Add product class UUIDs with printable, scannable QR labels 2026-07-13 17:12:13 +00:00
users.go Initial implementation of pantryapi 2026-07-11 17:54:12 +00:00

pantryapi

REST API for home pantry stock tracking, in Go + PostgreSQL. Stock is tracked on product classes ("whole wheat flour") per location as an immutable ledger; barcodes resolve via the eandb catalog API and map onto your own class taxonomy. Classes can be split ("sugar" → "white sugar" + "cane sugar") without losing history.

Everything runs in Docker:

cp .env.example .env      # set the secrets
docker compose up -d --build
docker compose run --rm test    # run the test suite

See api.md for the full endpoint reference, conventions and a curl walkthrough.

Database migrations

Migrations run automatically when the API starts — there is no separate migrate command. The numbered SQL files in migrations/ are embedded into the binary (go:embed) and applied in order at startup, each in its own transaction, guarded by a Postgres advisory lock so concurrent instances never race. Applied versions are tracked in the schema_migrations table.

So deploying new code applies its migrations:

docker compose up -d --build api

To add a migration, create the next migrations/NNNN_description.sql file and rebuild — nothing else to register. To inspect what has been applied:

docker compose exec db psql -U pantry -c 'TABLE schema_migrations'

Migrations are forward-only (no down scripts); write them additively and keep them compatible with the previous release when possible.

Web UI

A server-rendered web UI (pantryweb) is served by the web compose service on http://localhost:${PANTRYWEB_PORT:-8085}. Log in with the same credentials as the API (the bootstrap admin user from PANTRYAPI_ADMIN_PASSWORD works out of the box).

Barcodes can be entered manually (always works, including keyboard-wedge scanners) or scanned with the device camera — camera access requires a secure context (HTTPS or localhost), so put the web UI behind a TLS proxy for phone use, or use it on localhost during development.