This microservice is responsible for managing an e-commerce Wishlist. It is built using Java 17, Spring Boot, Gradle and MongoDB, and is designed to be deployed using Kubernetes.
This project uses another microservices to query product information and check for existing customers. The Project Wishlist Support API you will find an example microservices that provides the end-points with the necessary information for the correct functioning of this project.
To build and run this microservice, you will need the following:
- IntelliJ IDEA: For project development
- JDK 17: Required to run the Java project
- Gradle: Required to build the Java project
- MongoDB: Required to Database the project
- Docker: Required for deploy tho project
- Kubernetes: Required for deploy tho project
To build and run the microservice, you can choose one of the following options:
To run the project, you will need to following these steps:
- Clone the repository to your local machine.
- Configure the MongoDB connection and external API for products and clients in application.yml or the environment variables (VM Options).
-DMONGO_HOST='<Mongodb url connection>' -DMONGO_DB='<Data base name>' -DMONGO_USERNAME='<User name>' -DMONGO_PASSWORD='<Password>' -DAPI_CLIENT_URL='<External API client URL>' -DAPI_CLIENT_GET_EXISTS='<Path service get exists client>' -DAPI_PRODUCT_URL='<External API product URL>' -DAPI_PRODUCT_GET_PRODUCT='<Path service get product information>'
- Build the microservice WishlistApplication using Gradle:
gradle build
.
To run the project with docker, has an image hosted on the Docker Hub: https://hub.docker.com/repository/docker/raytottifa/wishlist-api
docker pull raytottifa/wishlist-api:latest
docker run -p 8080:8080
-e MONGO_HOST='<Mongodb url connection>'
-e MONGO_DB='<Data base name>'
-e MONGO_USERNAME='<User name>'
-e MONGO_PASSWORD='<Password>'
-e API_CLIENT_URL='<External API client URL>'
-e API_CLIENT_GET_EXISTS='<Path service get exists client>'
-e API_PRODUCT_URL='<External API product URL>'
-e API_PRODUCT_GET_PRODUCT='<Path service get product information>'
-e PORT=8080
wishlist-api
Deploy in your Kubernetes cluster following these steps:
- Apply the ConfigMap Mongo located at
./deploy/kubernetes
kubectl apply -f ./deploy/kubernetes/mongo-wishlist-config.yml
- Apply the Secret Mongo located at
./deploy/kubernetes
kubectl apply -f ./deploy/kubernetes/mongo-wishlist-secret.yml
- Apply the Deployment Mongo located at
./deploy/kubernetes
kubectl apply -f ./deploy/kubernetes/mongo-wishlist-deployment.yml
- Apply the ConfigMap Api located at
./deploy/kubernetes
kubectl apply -f ./deploy/kubernetes/wishlist-config.yml
- Apply the Deployment Api located at
./deploy/kubernetes
kubectl apply -f ./deploy/kubernetes/deployment.yml
One of the options is to use the Swagger that is configured in the application at path /swagger-ui/index.html
The following endpoints are available in the microservice:
- POST /api/v1/wishlists/clients/{clientId}/products - Add a new item to the list of product items for the informed clientId.
curl --location --request POST 'http://<applicationUrl>:<applicationPort>/api/v1/wishlists/clients/<clientId>/products' \
--header 'Content-Type: application/json' \
--data-raw '{
"productId":"<productId>"
}'
- DELETE /api/v1/wishlists/clients/{clientId}/products/{productId} - Remove an item from the list of product items for the informed clientId.
curl --location --request DELETE 'http://<applicationUrl>:<applicationPort>/api/v1/wishlists/clients/<clientId>/products/<productId>'
- GET /api/v1/wishlists/clients/{clientId} - Retrieve the list of favorite items for the informed clientId.
curl --location --request GET 'http://<applicationUrl>:<applicationPort>/api/v1/wishlists/clients/<clientId>'
- GET /api/v1/wishlists/clients/{clientId}/products/{productId}/exists - Checks if the informed product belongs to the list of product items for the informed clientId.
curl --location --request GET 'http://<applicationUrl>:<applicationPort>/api/v1/wishlists/clients/<clientId>/products/<productId>/exists'
This microservice provides a simple and scalable solution for managing an e-commerce Wishlist. By leveraging Java 17, Spring Boot, Gradle, and MongoDB, and deploying with Kubernetes, this microservice is well-equipped to handle large volumes of traffic and provide a seamless user experience.
- As a future implementation, we are going to implement the communication of this microservice with a messaging structure. with the intention of ensuring the integrity of product and customer data.