# Marketplace API NestJS API for the IranBay marketplace gate. ## Architecture (Meshkee) Two different Meshkee “business” concepts: 1. **IranBay platform tenant** (`iranbay.com`) — auth only. Customer accounts from IranBay login/register are linked here via `business_customers`. Not a Meshkee storefront. Bootstrap: `npm run bootstrap:iranbay` (needs Meshkee superadmin token). 2. **Producer shops** — each shop that registers on IranBay becomes a **separate** Meshkee business + an IranBay marketplace listing (`POST /businesses/register-shop`). Marketplace DB stores **only listing controls**: `meshkee_business_id`, `slug`, `status`, `is_featured`, `sort_weight`. Name, categories, and profile content live in **Meshkee**. ## Setup ```bash cd backend cp .env.example .env docker compose up -d npm install npm run prisma:generate npm run db:migrate npm run start:dev ``` API: http://localhost:3001/api/v1 Required for shop self-register / Meshkee write-through: ```bash MESHKEE_API_URL=https://api.meshkee.com/api/v1 MESHKEE_API_TOKEN= # Meshkee superadmin access token ``` Bootstrap platform tenant: ```bash MESHKEE_API_TOKEN=… \ MESHKEE_SUPERADMIN_CELL=+98… \ MESHKEE_SUPERADMIN_PASSWORD=… \ npm run bootstrap:iranbay ``` ## Routes (v1) | Method | Path | Notes | |--------|------|--------| | `GET` | `/businesses` | Marketplace listings | | `GET` | `/businesses/:slug` | Listing by slug | | `GET` | `/businesses/by-id/:id` | Listing by id | | `POST` | `/businesses/register-shop` | Auth user → new Meshkee shop + IranBay listing | | `POST` | `/businesses` | Link existing Meshkee business (admin) | | `PATCH` | `/businesses/:id` | Marketplace fields; name/slug/category → Meshkee | | `DELETE` | `/businesses/:id` | Remove listing |