0% found this document useful (0 votes)
5 views2 pages

Product Module Professional

The document outlines the API contract and business logic for a Product Module, detailing endpoints for creating, retrieving, updating, and deleting products. It specifies access levels for different user roles and includes response codes for each operation. Key features include pagination, filtering, and stock management for products.
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views2 pages

Product Module Professional

The document outlines the API contract and business logic for a Product Module, detailing endpoints for creating, retrieving, updating, and deleting products. It specifies access levels for different user roles and includes response codes for each operation. Key features include pagination, filtering, and stock management for products.
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Product Module - API Contract & Business Logic

1. Create Product

Method: POST
Endpoint: /api/products
Access: Auth (Vendor/Admin)

Controller:
- Extract vendorId from session/request
- Call service

Service:
- Generate slug & SKU
- Use transaction to create product, images, variants

Response: 201 Created

2. Get All Products

Method: GET
Endpoint: /api/products
Access: Public

Features:
- Pagination (page, limit)
- Filters (category, brand, price)
- Search (q)
- Sorting (price, newest)

Response: 200 OK with metadata

3. Get Product Detail

Method: GET
Endpoint: /api/products/:slug
Access: Public

Includes:
Category, Brand, Images, Variants, Reviews

Response: 200 OK

4. Update Product

Method: PATCH
Endpoint: /api/products/:id
Access: Admin/Owner
Logic:
- Partial update
- Image sync (delete + create)

Response: 200 OK

5. Stock Update

Method: PATCH
Endpoint: /api/products/:id/stock
Access: Vendor (Owner)

Logic:
- Atomic increment/decrement

Response: 200 OK

6. Delete Product

Method: DELETE
Endpoint: /api/products/:id
Access: Admin/Owner

Logic:
- If orders exist → Soft Delete
- Else → Hard Delete

Response: 204 No Content

You might also like