Skip to content

feat: Trade Matching & Suggestions module - #39

Merged
akargi merged 8 commits into
Chulilee:mainfrom
devIKargi:feat/TradeMachine
Aug 26, 2026
Merged

feat: Trade Matching & Suggestions module#39
akargi merged 8 commits into
Chulilee:mainfrom
devIKargi:feat/TradeMachine

Conversation

@devIKargi

Copy link
Copy Markdown

Closes #27

Body

Summary

Adds a lightweight trade matching system that ranks compatible listings for a given listing and lets users propose trades directly from the marketplace.

What's included

Matching algorithm (src/services/matchService.ts)

  • Scores candidates on three dimensions: category (40 pts), tag overlap via Jaccard similarity (35 pts), and value proximity (25 pts)
  • Excludes same-seller, inactive, and self-matches
  • Surfaces only matches above a configurable threshold, ranked by score

UI components

  • SuggestedMatches — displays ranked match cards with score breakdown bars, human-readable reasons, and a "Propose trade" action with optional message
  • ListingCard — new "Find matches" button per listing
  • ListingCreate — new tags input (Enter to add, clickable chips)
  • MarketplaceClient — "matches" view with back-navigation

Types & data (src/types/listing.ts)

  • Added tags: string[] to Listing
  • New types: MatchSuggestion, TradeMatchResult, TradeProposal, TradeProposalStatus
  • Seed data enriched with descriptive tags for all 5 listings

Proposal management (localStorage-backed)

  • proposeTrade, acceptProposal, declineProposal, getProposalsForListing

Analytics

  • Tracks listing_view (when viewing matches) and match_propose events via existing useAnalytics hook

Tests (src/services/__tests__/matchService.unit.test.ts)

  • 23 unit tests covering scoreCategory, scoreTags, scoreValue, and findMatches — including exclusion logic, ranking, breakdown integrity, and edge cases

Files changed (9 files, +954 / -13)

File Change
src/types/listing.ts tags on Listing, new match/proposal types
src/services/matchService.ts Matching algorithm + proposal CRUD
src/services/listingService.ts Tags in seed data
src/components/SuggestedMatches.tsx Match display + propose flow
src/components/MarketplaceClient.tsx Matches view routing
src/components/ListingCard.tsx "Find matches" button
src/components/ListingList.tsx Pass onFindMatches prop
src/components/ListingCreate.tsx Tags input
src/services/__tests__/matchService.unit.test.ts 23 unit tests

Verification

  • next build — compiled successfully
  • tsc --noEmit — zero type errors
  • next lint — no warnings or errors
  • jest — 125/125 tests pass (13 suites)

@akargi
akargi merged commit 9ce9d0b into Chulilee:main Aug 26, 2026
1 check passed
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.

Feature: Trade Matching & Suggestions module

2 participants