# Balout Pastry API NestJS + Prisma + PostgreSQL + JWT admin API for شیرینی‌فروشی بلوط. Lives in `Balout Pastry/Backend` next to `Dashboards/`. Not wired to the UI yet. ## Stack - NestJS 11 / TypeScript - Prisma 6 + PostgreSQL 16 (Docker Compose) - JWT access + refresh tokens - Parspack S3 (same credentials as Meshkee, prefix `balout/`) ## Quick start From this folder (`Backend/`): ```bash cp .env.example .env npm install npm run db:up npx prisma migrate deploy npm run create-super-admin -- --phone 09120000000 --password secret123 npm run start:dev # http://localhost:3100/api/v1 ``` ## Auth rules - Only `admin` and `superAdmin` can log in - Only `superAdmin` can assign `admin` or `superAdmin` roles - Customers exist for a future customer dashboard ## Main routes (`/api/v1`) | Area | Methods | |------|---------| | Auth | `POST /auth/login`, `/auth/refresh`, `/auth/logout`, `GET /auth/me` | | Users | CRUD + `PATCH /users/:id/role`, `/password` + addresses under `/users/:id/addresses` | | Flavors | CRUD | | Categories | tree CRUD + `GET|PUT /categories/:id/options` | | Products | CRUD (options must match category templates); list filters `q`, `categoryId`, `minPrice`, `maxPrice` | | Orders | `GET /orders`, `GET /orders/:id`, `POST /orders`, `PATCH /orders/:id/status` | | Media | `POST /media/upload?kind=main\|gallery\|temp` | | Settings | districts, shipping exceptions, branches | ## Orders Create body: ```json { "customerId": "...", "deliveryType": "pickup", "branchId": "...", "note": "optional", "items": [ { "productId": "...", "quantity": 2, "optionIds": ["..."] } ] } ``` For shipping, use `deliveryType: "shipping"` and `shippingAddressId` (from user addresses). Prices and names are snapshotted at create time. Display code is `BL-{number}`. ## Notes - Prices are integer **تومان** - Port **3100**; Postgres **5434** (Meshkee uses 3000 / 5432)