The idea here is to provide a complete backend for a checkout system. The products-api is just a mock.
The steps could read as:
- The frontend calls products-api, and renders the content to the user;
- After choosing the products, user procceeds on checking out, and the frontend sends the products list to checkout-api;
- checkout-api requests products data to products-api;
- checkout-api requests promotions data to promotions-api, then calculates the basket's total value and finaly answers it to the frontend;
The project is organized in directories that isolate the three applications, and a few other goodies at the root. Let's have a look:
- checkout-api: Project for the app that will actually do the maths and processing;
- promotions-api: Project for the app that manages promotions;
- products-api: Inside of this directory there is just the mocked API, plus one script used to start the WireMock Server inside a container;
- docs: This directory concentrates both the docs, the answers to the Follow-Up Questions and a collection of requests, that can be imported to Postman in order to consume the apps;
Basically just docker
and docker-compose
, in order run everything at once.
First, you'll have to build the apps:
$ cd promotions-api && ./gradlew clean build
$ cd checkout-api && ./gradlew clean build
Now we're ready to go:
$ docker-compose up
Now, to run each app individually, check out the README file for each of them.
There's a Postman collection under docs/requests directory. There's no promotions created by default, so you probably want to start by creating some of them, before proceeding to test the checkout.
It's the default for gradlew with spring applications, go to the desired app's root directory and run ./gradlew test
, or run them with the IDE of your choice.