Backend modules
Executive summary
Section titled “Executive summary”The API is organized into feature modules under apps/backend/src/modules/, imported by app.module.ts: auth, admin, vendor, point-of-sale (vendor POS v2 shell), pos, health, and a small read-only public surface for unauthenticated web clients. Each controller’s @Controller('…') path is served under the global prefix /api/v1. OpenAPI (Swagger) is the authoritative contract for request/response shapes; this page maps folders → HTTP prefixes so contributors land in the right module.
Goals and non-goals
Section titled “Goals and non-goals”| Goals | Non-goals |
|---|---|
| Map modules to route prefixes and main controller files | Duplicate every DTO property from Swagger here — use the Backend API catalog for the exhaustive list |
| Show where admin vs vendor vs POS live in the tree | Document legacy Laravel tables column-by-column |
| Support onboarding and code review (“is this the right module?”) | Replace integration tests or staging verification |
Current platform behavior
Section titled “Current platform behavior”Module → route prefix (after /api/v1)
Section titled “Module → route prefix (after /api/v1)”| Module | Role | Primary HTTP prefixes |
|---|---|---|
auth | Customer / shared Laravel-style envelope | auth |
admin | Admin JWT + zone/module guards | auth/admin, admin/* |
vendor | Vendor JWT, catalog, finance, POS data | auth/vendor, auth/vendor/context, vendor/* |
point-of-sale | Vendor POS v2 shell (JWT bootstrap only; legacy checkout unchanged) | vendor/point-of-sale |
pos | POS checkout, orders, terminal payment webhook | pos, pos/payments |
health | Health probe | health |
public-landing | Throttled public JSON for marketing UIs | public (e.g. GET …/public/landing-settings) |
Controllers by area (representative — Swagger is exhaustive)
Section titled “Controllers by area (representative — Swagger is exhaustive)”Auth (auth)
auth.controller.ts→@Controller('auth')
Admin (admin)
admin-auth.controller.ts→auth/adminadmin-dashboard.controller.ts→admin/dashboardadmin-products.controller.ts→admin/productsadmin-orders.controller.ts→admin/orders(platform B2Badmin_orders; new row ids useAUTO_INCREMENT≥ 100000 after migration1782470000000-AdminOrdersAutoIncrementMin100000)admin-zones.controller.ts→admin/zonesadmin-stores.controller.ts→admin/storesadmin-vendors.controller.ts→admin/vendorsadmin-warehouses.controller.ts→admin/warehousesadmin-suppliers.controller.ts→admin/suppliersadmin-managers.controller.ts→admin/managersadmin-roles.controller.ts→admin/rolesadmin-modules.controller.ts→admin/modulesadmin-employee-roles.controller.ts→admin/employee-rolesadmin-vendor-employees.controller.ts→admin/vendor-employeesadmin-stocks.controller.ts→admin/stocksadmin-lots.controller.ts→admin/lotsadmin-adjustments.controller.ts→admin/adjustmentsadmin-business-settings.controller.ts→admin/settings/business(store/contact + SMTPmail_*+ optional marketinglanding_*+admin_orders_default_tax_percentfor B2B admin orders inbusiness_settings,POST …/test-smtp)public-landing.controller.ts→public/landing-settings(no auth; readslanding_*+business_namefrombusiness_settingsfor web landing pages)
Vendor (vendor)
vendor-auth.controller.ts→auth/vendor(login, refresh, me, profile, notifications list)vendor-auth-context.controller.ts→auth/vendor/contextvendor-dashboard.controller.ts→vendor/dashboardvendor-products.controller.ts→vendor/productsvendor-orders.controller.ts→vendor/ordersvendor-finance.controller.ts→vendor/financevendor-stores.controller.ts→vendor/storesvendor-customers.controller.ts→vendor/customersvendor-inventory.controller.ts→vendor/inventoryvendor-stocks.controller.ts→vendor/stocksvendor-warehouses.controller.ts→vendor/warehousesvendor-lots.controller.ts→vendor/lotsvendor-adjustments.controller.ts→vendor/adjustmentsvendor-categories.controller.ts→vendor/categoriesvendor-units.controller.ts→vendor/unitsvendor-attributes.controller.ts→vendor/attributesvendor-tags.controller.ts→vendor/tagsvendor-suppliers.controller.ts→vendor/suppliersvendor-coupons.controller.ts→vendor/couponsvendor-roles.controller.ts→vendor/rolesvendor-employees.controller.ts→vendor/vendor-employeesvendor-modules.controller.ts→vendor/modulesvendor-settings.controller.ts/vendor-settings-context.controller.ts→vendor/settings
Point of Sale v2 shell (point-of-sale)
point-of-sale.controller.ts→vendor/point-of-sale(e.g.GET …/bootstrapfor workspace metadata; does not replacepos/*checkout routes)
POS (pos)
pos.controller.ts→pospos-payment-webhook.controller.ts→pos/payments
Health (health)
health.controller.ts→health
Examples (non-exhaustive)
Section titled “Examples (non-exhaustive)”- Admin:
GET/POST …/admin/products,…/admin/orders,…/admin/zones, … - Vendor:
…/vendor/products,…/vendor/orders,…/vendor/finance,…/vendor/point-of-sale/bootstrap, … - Auth:
…/auth/...for shared/customer flows;…/auth/admin/*,…/auth/vendor/*for JWT issuance and related actions.
Sequence: happy path (contributor)
Section titled “Sequence: happy path (contributor)”- Identify the actor (customer vs admin vs vendor vs POS device/webhook).
- Open the matching module folder under
src/modules/<name>/. - Find
*.controller.tswhose@Controllerprefix matches the URL you need. - Trace service → entities/repositories; add or extend
*.spec.tsfor behavior changes (Backend architecture for global concerns).
Security and operations
Section titled “Security and operations”- Guards differ by module: admin module keys and zone checks, vendor store scoping, POS payment verification for webhooks—never bypass in the controller without a service-level check.
- Prefer parameterized queries (TypeORM) over string concatenation; validate and sanitize DTO inputs for search filters.
- For diagrams and runbooks where behavior is not obvious from OpenAPI (webhooks, idempotency, PSP retries), add or link sequence docs—see POS payments & webhooks.
Test scenarios (contributors / QA)
Section titled “Test scenarios (contributors / QA)”| ID | Scenario | Expected |
|---|---|---|
| BM1 | New route in correct module | Swagger shows path under /api/v1 |
| BM2 | Change to guarded admin route | Unit/integration tests cover allow/deny |
| BM3 | Webhook endpoint | Signature + idempotency tests where applicable |
Related
Section titled “Related”- System test cases (index) — cross-cutting TC- ids, unhappy paths, E2E notes
- Backend architecture (NestJS) — bootstrap, globals, Throttler, ValidationPipe
- API conventions — Swagger base URL and clients
- Authentication — JWT entrypoints