deckhearth/.convoys/pricing-online-local/brief-8-card-pricing-apis.md
Randall Stillwell d0468015eb
Some checks failed
CI / Lint (pull_request) Has been cancelled
CI / Schema map up to date (pull_request) Has been cancelled
CI / Forbidden patterns (9 checks) (pull_request) Has been cancelled
CI / Migrations apply (node-pg-migrate) (pull_request) Has been cancelled
Visual diff / Should run? (pull_request) Has been cancelled
CI / Unit tests (vitest) (pull_request) Has been cancelled
Convoy metrics gate / Require role-event telemetry on convoy PRs (pull_request) Has been cancelled
PR Health rollup / Aggregate gate status (pull_request) Has been cancelled
Preview smoke / Should run? (pull_request) Has been cancelled
Preview smoke / Playwright smoke (pull_request) Has been cancelled
Visual diff / Screenshot diff (pull_request) Has been cancelled
feat(pricing): convoy for online prices and local stores
Add pricing schema, free API integrations (MTG bulk, TCGdex, Foolio),
valuation and sort-by-price, card detail pricing UI, and nearby store
discovery via home zip and OSM geo clients.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-09-08 22:47:46 -05:00

1.9 KiB

convoy brief_number depends_on recommended_model model_tier files cross_brief_commitments
pricing-online-local 8
2
composer-2.5 standard
lib/pricing/pricing-service.js
pages/api/cards/[id]/pricing.js
pages/api/cards/[id]/price-history.js
pages/api/cards/[id].js
test/api/cards-pricing.test.js
test/api/cards-price-history.test.js
brief description
9 Response shapes from `/api/cards/[id]/pricing` and `/api/cards/[id]/price-history` are the contract Brief 9's UI consumes. Do not rename fields without updating Brief 9.

Brief 8: Card pricing + history APIs

Goal (1 sentence)

Expose GET /api/cards/[id]/pricing and GET /api/cards/[id]/price-history reading DB with optional stale refresh.

Files in scope (do not edit anything else)

  • lib/pricing/pricing-service.js
  • pages/api/cards/[id]/pricing.js
  • pages/api/cards/[id]/price-history.js
  • pages/api/cards/[id].js
  • test/api/cards-pricing.test.js
  • test/api/cards-price-history.test.js

Conventions to follow

  • API route pattern from .cursor/rules/api-routes.mdc: method gate, try/catch, manual validation.
  • pricing-service.js: DB-first; live refresh only when stale >24h with Redis single-flight lock.
  • Include outbound links via outbound-links.js.
  • price-history.js API: query card_price_history last N days (default 90, max 365).

Acceptance criteria

  • GET /api/cards/123/pricing returns prices + pricesUpdatedAt + stale boolean
  • GET /api/cards/123/price-history?days=30 returns { points: [...] }
  • 404 when card missing; 400 on invalid id/days
  • Live refresh does not throw on upstream failure
  • Tests pass
  • No scope expansion

Rationale (≤3 sentences)

Phase 1 backend contract for Purchase and Price History tabs. DB-first path respects free API limits; 24h staleness matches convoy spec.