Overview
Viridian Vault is an internal web platform for a small Pokémon TCG resale operation. It tracks inventory, keeps market prices synced via the PokeWallet API, and surfaces cost basis vs. market value so you can see unrealized profit at both the item and portfolio level.
The core engineering problem is identity: inventory is entered in human terms (name, set, number), but pricing requires a provider product ID. Viridian Vault solves that with a progressive multi-stage resolution cascade and an admin workflow for ambiguous matches.
Problem & Context
Manual price lookups don’t scale, and show-event workflows are time-sensitive. The owners needed a system that could:
- Resolve inventory items to provider IDs reliably
- Fetch prices without violating rate limits
- Cache and snapshot prices for trend tracking
- Stay internal-only with real access control
Constraints
- External API rate limits require cache-first design.
- Internal-only access (no self-registration) via allowlist.
- All writes go through server route handlers; no direct client mutations.
Approach & Design Decisions
- Persistent candidates: multi-match resolution results are stored in a
resolution_candidatestable so ambiguity survives navigation and supports async admin resolution. - Cache-first pricing: reads hit
price_current; refresh happens only when stale, in batches sized for provider limits. - RLS as a hard gate: forced row-level security with policies checking
allowed_users. - Incremental migrations: versioned SQL migrations document the schema and policy evolution.
Implementation Highlights
- Resolution cascade v2: 4-stage fallback (set_code+number → title+set_code+number → title+number → title-only), now with set_code first for higher hit rate on singles.
- Typed discriminated union outputs (resolved/candidates/not_found) for debuggability;
post_filter_countadded in AttemptLog. - Price cache TTL and snapshot system with reason tags (DAILY/MANUAL/SHOW/TRANSACTION_EVENT).
- Card image fetch as bytes → Supabase Storage for singles.
- Pipeline audit hardening (v1.6.0): atomic price writes, quota tracking, thundering-herd guard, image fetch hardening, TTL centralization, set-mapping TTL.
Results & Evaluation
The implemented core includes inventory management, provider resolution, a pricing cache, access policies, and scheduled snapshots. Pipeline hardening added atomic price writes, quota tracking, concurrent-refresh protection, and centralized TTL handling.
The resolution workflow returns explicit resolved, candidate, or not-found outcomes so ambiguous inventory can be reviewed without silently accepting an incorrect provider match.
Status & Next Steps
The implemented inventory and pricing core is distinct from planned extensions. A unified resolution workspace, show-mode transaction flows, hourly background sync, analytics, and binder scanning are not presented here as completed. Public usage and long-term resolution success metrics are not available.
Validation & Further Work
Typed outcomes, Zod validation, database policies, and atomic updates define checks at API and persistence boundaries. Further evaluation should measure resolution quality against reviewed inventory and exercise provider failures and refresh concurrency at representative scale.
Tradeoffs & Limitations
- Internal-only; demo and repo links omitted.
- Provider resolution is probabilistic; the admin workflow is essential for long-tail edge cases.