This project is a reactive RESTful API for managing a product catalog. It is written in Java and uses reactive programming with Spring WebFlux and MongoDB.
Note: This API is part of a larger e-commerce system that includes user management and order management. To run the complete system, you must also run the WebFlux Users API, the WebFlux Orders API, and the WebFlux E-commerce API Gateway. The API Gateway provides a unified interface to the entire system and manages communication between the individual APIs.
- Java 11 or higher
- MongoDB
- Clone the repository:
git clone https://github.com/anabeatrizdmt/webflux-catalog.git
- Install dependencies:
cd webflux-catalog
mvn install
- Run the application:
mvn spring-boot:run
To create a new product, send a POST
request to http://localhost:8080/catalog
with a JSON payload in the following format:
{
"name": "Product Name",
"price": 10.99,
"availableQuantity": 100
}
To retrieve a list of all products, send a GET
request to http://localhost:8080/catalog
.
To retrieve a specific product by its ID, send a GET
request to http://localhost:8080/catalog/{id}
, where {id}
is the ID of the product you wish to retrieve.
To check the stock of one or more products, send a POST
request to http://localhost:8081/catalog/stock
with a JSON payload in the following format:
[
"product-id-1",
"product-id-2",
...
]
To update the stock of one or more products, send a POST
request to http://localhost:8080/catalog/update-stock
with a JSON payload in the following format:
[
{
"productId": "product-id-1",
"purchasedQuantity": 1
},
{
"productId": "product-id-2",
"purchasedQuantity": 3
},
...
]