Skip to content

Market Module

Public Summary

Store locations with GeoJSON coordinates, chain association, and product pricing integration.

Internal Details

Files

Standard CRUD layer: controller, service, routes, schema, model, repository (7 files).

Endpoints

MethodPathAuthDescription
GET/marketsPublicList markets (searchable by name/chain)
GET/markets/:idPublicMarket detail with products
POST/marketsJWTCreate market
PUT/markets/:idJWTUpdate market
DELETE/markets/:idJWTDelete market + cascade

Data Model — Market

name             : String (required)
location         : [Number, Number] — [longitude, latitude]
chain            : ObjectId → Chain (required)
lastScrapedUpdate: Date

Virtual: products — populated via MarketProduct back-reference.

GeoJSON Convention

Coordinates are stored as [longitude, latitude] (GeoJSON order), not [lat, lon].

Cascade Delete

Deleting a market removes all MarketProduct junction records for that market.

Source Anchors

PathRelevance
apps/server/src/modules/market/Controller, service, routes, schema, model, repository

Student Obrok engineering documentation.