Code Monkey home page Code Monkey logo

wishlist's Introduction

Wishlist Microservice API

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.

Requirements

To build and run this microservice, you will need the following:

Getting Started

To build and run the microservice, you can choose one of the following options:

With IDE

To run the project, you will need to following these steps:

  1. Clone the repository to your local machine.
  2. 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>'
    
  3. Build the microservice WishlistApplication using Gradle: gradle build.

With Docker

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

With Kubernetes

Deploy in your Kubernetes cluster following these steps:

  1. Apply the ConfigMap Mongo located at ./deploy/kubernetes
     kubectl apply -f ./deploy/kubernetes/mongo-wishlist-config.yml
  2. Apply the Secret Mongo located at ./deploy/kubernetes
     kubectl apply -f ./deploy/kubernetes/mongo-wishlist-secret.yml
  3. Apply the Deployment Mongo located at ./deploy/kubernetes
    kubectl apply -f ./deploy/kubernetes/mongo-wishlist-deployment.yml
  4. Apply the ConfigMap Api located at ./deploy/kubernetes
    kubectl apply -f ./deploy/kubernetes/wishlist-config.yml
  5. Apply the Deployment Api located at ./deploy/kubernetes
    kubectl apply -f ./deploy/kubernetes/deployment.yml

Endpoints

One of the options is to use the Swagger that is configured in the application at path /swagger-ui/index.html

Swagger

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'

Conclusion

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.

TODO

  • 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.

wishlist's People

Contributors

raytotti avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.