Files
GearBox/.planning/phases/33-currency-system/33-01-SUMMARY.md
2026-04-13 18:02:57 +02:00

1.7 KiB

Plan 33-01 Summary

Status: Complete Completed: 2026-04-13

What Was Built

Database schema foundation for market-aware pricing and a currency conversion service.

Key Changes

  • Added market_prices table (globalItemId, market, currency, priceCents, source) with unique constraint
  • Added community_prices table (globalItemId, userId, market, currency, priceCents, priceDate, sourceType) with unique constraint
  • Added priceCurrency column to items table (default 'EUR')
  • Added foundPriceCents, foundPriceCurrency, foundPriceDate columns to thread_candidates
  • Created currency.service.ts with frankfurter.app rate fetching, 24h caching, and conversion math
  • Added Zod schemas for market price and community price validation
  • Exported new types (MarketPrice, CommunityPrice, UpsertMarketPrice, SubmitCommunityPrice)

Key Files Created/Modified

  • src/db/schema.ts — New tables + columns
  • src/shared/schemas.ts — New validation schemas
  • src/shared/types.ts — New type exports
  • src/server/services/currency.service.ts — Exchange rate service
  • tests/services/currency.service.test.ts — 12 unit tests

Self-Check: PASSED

  • market_prices table defined with correct columns and constraint
  • community_prices table defined with correct columns and constraint
  • items.priceCurrency column added
  • threadCandidates foundPrice fields added
  • Currency service fetches, caches, converts
  • All 12 tests pass

Decisions Made

  • Used separate tables for market prices and community prices (not JSONB)
  • EUR as default price currency matching existing data assumption
  • Module-level caching for exchange rates (simple, effective for single-process)