Skip to content

Product Module

Public Summary

Product catalog with multi-market pricing via a junction table. Supports category filtering, price ranges, and market-scoped queries.

Internal Details

Files

FileRole
product.controller.jsHTTP handlers
product.service.jsBusiness logic
product.routes.jsRoute definitions
product.schema.jsZod validation
product.model.jsMongoose Product schema
product.repository.jsProduct data access
marketProduct.model.jsJunction table schema
marketProduct.repository.jsJunction data access

Endpoints

MethodPathAuthDescription
GET/productsPublicList products (filter by title, category, market, price range)
GET/products/categoriesPublicCategory list (optionally scoped to market)
GET/products/:idPublicProduct detail
POST/productsJWTCreate product
PUT/products/:idJWTUpdate product
DELETE/products/:idJWTDelete product

Data Models

Product

title      : String (unique, required)
category   : String (required)
description: String
image      : ObjectId → Image (optional)

MarketProduct (junction table)

market  : ObjectId → Market (required)
product : ObjectId → Product (required)
price   : Number (required)

Unique compound index on (market, product) — one price per product per market.

Many-to-Many Relationship

Source Anchors

PathRelevance
apps/server/src/modules/product/Controller, service, routes, schema, models (Product + MarketProduct)

Student Obrok engineering documentation.