ProductController provides REST get, import and sell API for the product-service.
Product controller provides these endpoints:
POST: /api/v1/products/import
GET: /api/v1/products
DELETE: /api/v1/products/{id}/sell
Product service is the logic of the application. It persists products and related articles using productRepository and articleRepository.
Product service provides create, creatAll, update, get, sellProduct, productParser and delete functions.
Product is the main domain and aggregate of the product-service project.
ProductTo is Data Transfer Object(DTO) for the product domain model.
maps product domains to product transfer object and vice versa.
Is repository of product object. Does the main CRUD operations on the persistence layer.
ArticleController provides REST import API for the article-service.
Article controller provides this endpoint:
POST: /api/v1/articles/import
Article service is the logic of the article unit. It persists articles by using articleRepository.
Article service provides create, creatAll, update, get, sell, articleParser and delete functions.
Article is the main domain and aggregate of the article-service project.
ArticleTo is Data Transfer Object(DTO) for the article domain model.
maps article domains to article transfer object and vice versa.
Is repository of article object. Does the main CRUD, findByArticleId operations on the persistence layer.
To use this application make sure docker-compose is up see here. Then run project and import inventory and products file. So you can try to sell product ;).
curl --location --request POST 'localhost:8080/api/v1/articles/import' \
--form 'inventory=@"/Users/mohammadmasoomi/Downloads/back-end-software-engineer-candidate-assignment/inventory.json"'
curl --location --request POST 'localhost:8080/api/v1/products/import' \
--form 'products=@"/Users/mohammadmasoomi/Downloads/back-end-software-engineer-candidate-assignment/products.json"'
curl --location --request GET 'localhost:8080/api/v1/products'
curl --location --request DELETE 'localhost:8080/api/v1/products/1/sell'
To start MySql cd to docker folder and then run this command:
$ ./docker-compose -up
Maven is on charge for this project. To build this project on the root of the project run this command:
$ mvn clean package
-
Integration test
I liked to add integration tests(API tests) for REST services in the next release.
-
Performance
In order to creat products we can use other match algorithms.