Skip to content

feat: external catalog search endpoint for item autofill#6

Merged
dhighwayman merged 1 commit into
masterfrom
feat/external-search
May 31, 2026
Merged

feat: external catalog search endpoint for item autofill#6
dhighwayman merged 1 commit into
masterfrom
feat/external-search

Conversation

@dhighwayman

Copy link
Copy Markdown
Contributor

What

Adds a new auth-guarded GET /search/?q= endpoint that powers a search-as-you-type "Item name" field on the frontend. It queries three free catalogs concurrently and returns a normalized result shape ({category, name, url, pic_url, description}):

  • 📚 Books → Open Library (keyless)
  • 🎬 Movies & TV → TMDB (needs TMDB_API_KEY; degrades to empty results if unset)
  • 🎵 Music → iTunes Search API (keyless)

How

  • New internal/search vertical slice (dto.go / service.go / api.go), mirroring the existing domain layout and wired by hand in cmd/backend/main.go.
  • Search(q) fans the three providers out with a sync.WaitGroup over a shared http.Client{Timeout: 4s}. A provider that errors contributes an empty slice rather than failing the whole search.
  • Registered as an auth-guarded route (registerSearchRoutes), consistent with other mutating routes.
  • CreateItem no longer clobbers a client-supplied pic_url: it only scrapes og:image when no picture was provided — so a search-autofilled cover survives.
  • TMDB_API_KEY added to config.go (default empty).

Config / deploy

TMDB_API_KEY must be set on the back Cloud Run service (the deploy workflow sets no env vars, so service-level env/secrets persist across deploys):
gcloud run services update back --update-env-vars TMDB_API_KEY=<key>. Free key from themoviedb.org → Settings → API. Open Library and iTunes need no key.

Notes

  • The matching frontend change (typeahead UI) lives in the front repo and depends on the pending React 18 upgrade there; it is not in this PR.
  • Could not go build/go test locally (no Go toolchain on the dev machine) — relying on the go.yml build+test CI on this PR.

🤖 Generated with Claude Code

Add GET /search/?q= (auth-guarded) that queries three free catalogs
concurrently and returns normalized results so the frontend can autofill
an item's name, URL and picture:

- Books: Open Library (keyless)
- Movies & TV: TMDB (needs TMDB_API_KEY; degrades to empty if unset)
- Music: iTunes Search API (keyless)

internal/search holds the dto/service/api slice; the service fans the
providers out with a WaitGroup over a shared http.Client with a 4s
timeout, and a failing provider yields no results rather than failing the
whole search. Wired in main.go and registered as an auth-guarded route.

Also stop CreateItem from clobbering a client-supplied pic_url: only
scrape og:image when no picture was provided. Adds TMDB_API_KEY to config.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@dhighwayman dhighwayman merged commit 165f712 into master May 31, 2026
2 checks passed
@dhighwayman dhighwayman deleted the feat/external-search branch May 31, 2026 08:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant