- Go 86%
- HTML 9%
- JavaScript 1.8%
- CSS 1.7%
- Shell 1.4%
- Other 0.1%
| .woodpecker | ||
| migrations | ||
| web | ||
| .env.example | ||
| .gitignore | ||
| api.md | ||
| auth.go | ||
| auth_test.go | ||
| classes.go | ||
| docker-compose.yaml | ||
| Dockerfile | ||
| Dockerfile.web | ||
| eandb.go | ||
| go.mod | ||
| go.sum | ||
| groups.go | ||
| handlers.go | ||
| handlers_test.go | ||
| history_test.go | ||
| internal_ean_test.go | ||
| locations.go | ||
| main.go | ||
| pagination_test.go | ||
| products.go | ||
| README.md | ||
| scan.go | ||
| scan_test.go | ||
| shopping.go | ||
| shopping_test.go | ||
| split.go | ||
| split_test.go | ||
| stock.go | ||
| stock_test.go | ||
| store.go | ||
| store_test.go | ||
| taxonomy_test.go | ||
| users.go | ||
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.