Files
reactbin/specs/007-tag-browser/data-model.md
agatha 355014f975 Feat: Add tag browser page at /tags with count-sorted tag list and library deep-link
- Extends GET /api/v1/tags with sort=count_desc and min_count query params
- New TagsComponent at /tags (public, no auth guard) shows all tags sorted by image count
- Clicking a tag navigates to /?tags=<name> for a pre-filtered library view
- LibraryComponent reads ?tags= query param on init to support deep-linking from tag browser
- Library header gains a "Browse tags" link to /tags for discoverability
- All 15 TDD tasks complete; ruff, ng lint, and ng build clean

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-06 18:40:06 +00:00

1020 B

Data Model: Tag Browser

No schema changes are required for this feature. All data needed to power the tag browser already exists.

Derived Entity: Tag with Count

The tag browser displays a read-only, derived view of existing data:

Field Source Notes
name tags.name Lowercase, normalised string
image_count COUNT(image_tags.image_id) WHERE image_tags.tag_id = tags.id Computed at query time

This is exactly the shape already returned by GET /api/v1/tags as {"id", "name", "image_count"}.

What Changes

The query in TagRepository.list_tags() gains two optional behaviours:

  1. Sort by count descending — adds ORDER BY image_count DESC, name ASC (count-desc primary, alphabetical secondary) instead of the current ORDER BY name ASC.
  2. Exclude zero-count tags — adds HAVING image_count > 0 (or equivalent WHERE on the subquery) when min_count=1 is requested.

No new tables, columns, indexes, or migrations are needed.