feat(api): catalog places - parks, gates, park categories, category types, categories (#16) #80

Merged
amiryahaya merged 4 commits from feat/catalog-parks into main 2026-10-23 06:02:20 +02:00
Owner

Closes #16.

What

Catalog places: parks, gates, park categories (tags), category types and categories.

  • Migration 0006: six tables (UUIDv7, audit stamping, row auditing). Parks and gates are soft-deleted (deleted_at/deleted_by; a removed park takes its gates and frees its name). Names and codes are unique case-insensitively, coordinates range-checked, categories nest (no self-parent in the database, deeper cycles refused by the store under an advisory lock).
  • API (internal/catalog): public cacheable reads (/v1/parks, /v1/parks/{id} with gates, /v1/parks/{id}/gates, /v1/park-categories, /v1/category-types, /v1/categories), no cost centre and active rows only. Admin CRUD under /v1/admin/... needs admin_portal.administration.manage; updates send version (409 when stale), deletes send ?version=; a park update replaces its tags in the same transaction.
  • Shared plumbing extracted so lookups, catalog and the coming products/prices (#17) do not copy it: internal/rest (create/update/delete handlers, strict bodies, cacheable responses, error mapping) and internal/rest/pgrest (list, optimistic update, constraint mapping). Lookups now uses them too.
  • Standards review: store interfaces are split per aggregate (ISP) in catalog and lookups, with the composite Store only for wiring. This was a gap in my first version (fat 14 and 17 method interfaces) and is fixed here.

Verification

  • Tests written first for the migration, validation, handlers (fake store and fake guard), store (real Postgres) and end to end through the real guard. Mutation check: breaking the cycle check fails its test.
  • make lint 0 issues, make cover 93.7% total (catalog 100%, catalog store 94.4%, rest 92.7%, pgrest 94.1%), govulncheck clean, down migration round-trips.

Known limits (documented in code)

  • Changing only a park's tags does not bump its version, so two admins editing only tags can overwrite each other.
  • Request bodies are capped at 64 KB (very long park texts would need a higher cap).
  • Moving a gate to a park that was soft-deleted is not blocked.
  • One process-honesty note: when I extracted internal/rest I moved the code first and wrote its tests afterwards; lookups' existing tests guarded that move.

Not in this PR

Media, products, park-products and prices (#17/#18), settings and forms (#19).

🤖 Generated with Claude Code

Closes #16. ## What Catalog places: parks, gates, park categories (tags), category types and categories. - **Migration 0006**: six tables (UUIDv7, audit stamping, row auditing). Parks and gates are soft-deleted (`deleted_at`/`deleted_by`; a removed park takes its gates and frees its name). Names and codes are unique case-insensitively, coordinates range-checked, categories nest (no self-parent in the database, deeper cycles refused by the store under an advisory lock). - **API** (`internal/catalog`): public cacheable reads (`/v1/parks`, `/v1/parks/{id}` with gates, `/v1/parks/{id}/gates`, `/v1/park-categories`, `/v1/category-types`, `/v1/categories`), no cost centre and active rows only. Admin CRUD under `/v1/admin/...` needs `admin_portal.administration.manage`; updates send `version` (409 when stale), deletes send `?version=`; a park update replaces its tags in the same transaction. - **Shared plumbing** extracted so lookups, catalog and the coming products/prices (#17) do not copy it: `internal/rest` (create/update/delete handlers, strict bodies, cacheable responses, error mapping) and `internal/rest/pgrest` (list, optimistic update, constraint mapping). Lookups now uses them too. - **Standards review**: store interfaces are split per aggregate (ISP) in catalog *and* lookups, with the composite `Store` only for wiring. This was a gap in my first version (fat 14 and 17 method interfaces) and is fixed here. ## Verification - Tests written first for the migration, validation, handlers (fake store and fake guard), store (real Postgres) and end to end through the real guard. Mutation check: breaking the cycle check fails its test. - `make lint` 0 issues, `make cover` 93.7% total (catalog 100%, catalog store 94.4%, rest 92.7%, pgrest 94.1%), govulncheck clean, down migration round-trips. ## Known limits (documented in code) - Changing only a park's tags does not bump its version, so two admins editing only tags can overwrite each other. - Request bodies are capped at 64 KB (very long park texts would need a higher cap). - Moving a gate to a park that was soft-deleted is not blocked. - One process-honesty note: when I extracted `internal/rest` I moved the code first and wrote its tests afterwards; lookups' existing tests guarded that move. ## Not in this PR Media, products, park-products and prices (#17/#18), settings and forms (#19). 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Strict body decoding, generic Create/Update with optimistic locking, cacheable list responses and
the store-error to problem mapping now live in internal/rest so the catalog modules reuse them.
Lookups behaviour is unchanged (its tests pass untouched).

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Migration 0006 adds the six tables (UUIDv7, audit stamping and row auditing); parks and gates are
soft-deleted, a removed park takes its gates and frees its name. internal/catalog serves public
cacheable reads (no cost centre) and admin CRUD under /v1/admin gated by administration.manage,
with optimistic locking, tag replacement, versioned soft delete and category cycle detection.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
refactor(api): segregate store interfaces per aggregate (ISP) in catalog and lookups
All checks were successful
ci / changes (pull_request) Successful in 7s
ci / api (pull_request) Successful in 3m52s
ci / ci-gate (pull_request) Successful in 4s
5d306adb1f
Handlers now hold only the narrow interface they use; the composite Store remains for wiring.
Records the development standards in CLAUDE.md.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
primatekuntech/kws!80
No description provided.