Matching users based on what they have and what they need

I’m in the beginning stages of creating a small trading app, where users will have a type of product in their inventory and also have a product they desire to have. I was curious if anyone could help me model this out. To make it simpler, there is only going to be one main product, with the possibility of many different types.

How can I match users that have something that other users want, so that they don’t have to go searching for the perfect trade but users are programmatically matched.

I imagine potential models will be:
User
Inventory
held_product
desired_product
Comment
Message

I hope this makes sense. My primary question is the issue of matching users based on matching attributes of held_product and desired_product.

Thanks so much!

Consider a single model that unifies held_product and desired_product. I’m guessing these differ only by a single field: does the user have the product already or is the user looking to acquire the product?

items

  • product_id
  • user_id
  • status (available, wishlist)

Then for a given wish list item, find corresponding entries where the status = ‘available’.