Base URL
All product endpoints are prefixed with/orders/products
Get Product by ID
Retrieve detailed information about a specific product.Path Parameters
The unique identifier of the product
Response
Unique identifier of the product
Name of the product
Price of the product in decimal format
Current stock quantity available
Response Example
Create Product
Create a new product in the system.Request Body
Name of the product. Must not be null.Validation:
@NotNullPrice of the product. Must be a positive number.Validation:
@PositiveInitial stock quantity. Must be zero or positive.Validation:
@PositiveOrZeroRequest Example
Response
Returns aProductResponse object with the created product details including the generated productID.
Auto-generated unique identifier
Name of the product
Price of the product
Current stock quantity
Response Example
When a product is successfully created, a
ProductCreatedInternalEvent is published to the RabbitMQ exchange for downstream processing.Update Product
Update an existing product’s information.Path Parameters
The unique identifier of the product to update
Request Body
Updated product nameValidation:
@NotNullUpdated product price. Must be positive.Validation:
@PositiveUpdated stock quantity. Must be zero or positive.Validation:
@PositiveOrZeroResponse
Returns the updatedProductResponse object.
Delete Product
Delete a product from the system.Path Parameters
The unique identifier of the product to delete
Response
Returns HTTP 204 No Content on successful deletion.Sell Product
Process a product sale transaction. This endpoint handles inventory deduction and publishes sale events for downstream processing.Path Parameters
The unique identifier of the product to sell
Request Body
The number of units to sell
Request Example
Response
Returns HTTP 202 Accepted, indicating the sale request has been received and is being processed asynchronously.The endpoint automatically captures the client IP address from the HTTP request for fraud detection and monitoring purposes.
Event Flow
When a sale is processed:- The product stock is decremented by the requested quantity
- A
ProductSoldInternalEventis published to RabbitMQ - The Sentinel service consumes this event for fraud detection
- If suspicious activity is detected, an
AlertInternalEventis generated - The Notify service receives alerts and sends notifications
Data Models
ProductRequest
Used for creating and updating products.ProductResponse
Returned when retrieving or modifying products.BuyRequest
Used for product sale transactions.Error Responses
All endpoints may return the following error responses:| Status Code | Description |
|---|---|
| 400 | Bad Request - Invalid input data or validation failure |
| 404 | Not Found - Product does not exist |
| 500 | Internal Server Error - Unexpected server error |