- Spring Boot 2.0.4 for writing Microservice
- STS(Spring tool suite) for code development
- Swagger for API documentation
- In memory derby database
- Maven for dependency management
- Docker for containerizing the solution
You can do below things via rest services
- Submit product review.
- Retrive the average rating and number of review for products.
- Get the complete product info along with reviews
Overall Solution contains 2 microservices(Product Info and Product Review), running in separate docker containers.
- Product review service , which opens endpoint to accept reviews for the product as well as allows to update and delete reviews
- Product review service also provide end point to retrieve Average product rating with number of reviews information.
- Product Info service allows to get the complete product info along with product reviews.
-
Proper timeouts has been configured for /product/{productId} endpoint , In case of review service is down or not responsing in 2 seconds , only product info excluding reviews will be returned in response. This makes product service higly available and lossely coupled with review service.
-
To minimize the number of database calls and make reveiw service more efficient, caching has been implemneted for many database calls.
-
Put the logs of product review service in TRACE mode and run the below command to see cache uses
-
tail -f spring.log | egrep -i "cache entry|invalidating"
-
For big installation separate redis server for cache can be deployed. Other caching solution can also be configured for highly sccalable and available solutions.
-
Centralized Exception handling is implemented and all the execptions would be redirected to global exception handler and from there final response would be sent to rest client with proper exception message.
-
All updates are protected by spring Security (Basic Authentication username = manish , pasword=manish1$3)
These instructions will get you a copy of the project up and running in your local machine for development and testing purposes. See deployment notes below to get the project deployed in your machine.
- If you want to follow docker deployment instructions Docker machine should be up and running and docker-compose should be installed for containerized deployment
- For normal instruction maven and java should be installed.
- git clone https://Manishmbm2010@bitbucket.org/Manishmbm2010/adidasproductreview.git
- cd adidasproductreview/AdidasProductReview
- docker run -it --rm -v "$PWD":/usr/src/app/ --volume "$HOME"/.m2:/root/.m2 -w /usr/src/app/ maven:3-jdk-8-alpine mvn clean install
- cd ../AdidasProductInfo/
- sed -i -e "s/localhost/adidasproductreview/g" src/main/resources/application.properties
- docker run -it --rm -v "$PWD":/usr/src/app/ --volume "$HOME"/.m2:/root/.m2 -w /usr/src/app/ maven:3-jdk-8-alpine mvn clean install
- docker-compose up --build
- git clone https://Manishmbm2010@bitbucket.org/Manishmbm2010/adidasproductreview.git
- cd adidasproductreview/AdidasProductReview/
- mvn clean install
- java -jar ./target/adidas-product-review-1.0.jar
- cd ../AdidasProductInfo
- mvn clean install
- java -jar ../AdidasProductInfo/target/adidas-product-info-1.0.jar
-
http://localhost:8081/review/ (method=POST)
-
Input Data : {"userId":"Manish", "productId": "M20324","rating":2.5 }
-
http://localhost:8081/review/{productId} (method=GET)
-
http://localhost:8081/review/{userId}/{productId} (method=PATCH)
-
Input : {"rating":6.5 }
-
Output : {"productId": "M20324", "userId": "Manish", "rating": 6.5}
-
http://localhost:8081/review/{userId}/{productId} (method=DELETE)
-
http://localhost:8081/review/admin/health (method=GET)
-
Swagger UI
-
http://localhost:8080/product/{productId} (method=GET)
-
http://localhost:8081/review/health (method=GET)
-
Swagger UI
- Maven - Dependency Management
- Currently solution has been designed with embedded derby database , can be configured with separate standalone database infa for persistent storage.
- Logging can be enhanced.
- Comments can be improved and extended further to make the maintenace of code much simpler later on.
Manish Jain