The Store application keeps track of customers and orders in a database.
This README assumes you're using a posix environment. It's possible to run this on Windows as well:
- Instead of
./gradlewusegradlew.bat - The syntax for creating the Docker container is different. You could also install PostgreSQL on bare metal if you prefer
This service assumes the presence of a postgresql 16.2 database server running on localhost:5433 (note the non-standard port)
It assumes a username and password admin:admin can be used.
It assumes there's already a database called store
You can start the PostgreSQL instance like this:
docker run -d \
--name postgres \
--restart always \
-e POSTGRES_USER=admin \
-e POSTGRES_PASSWORD=admin \
-e POSTGRES_DB=store \
-v postgres:/var/lib/postgresql/data \
-p 5433:5432 \
postgres:16.2 \
postgres -c wal_level=logicalYou should be able to run the service using
./gradlew bootRunThe application uses Liquibase to migrate the schema. Some sample data is provided. You can create more data by reading the documentation in utils/README.md
An order has an ID, a description, and is associated with the customer which made the order. A customer has an ID, a name, and 0 or more orders.
Two endpoints are provided:
- /order
- /customer
Each of them supports a POST and a GET. The data model is circular - a customer owns a number of orders, and that order necessarily refers back to the customer which owns it. To avoid loops in the serializer, when writing out a Customer or an Order, they're mapped to CustomerDTO and OrderDTO which contain truncated versions of the dependent object - CustomerOrderDTO and OrderCustomerDTO respectively.
The API is documented in the OpenAPI file OpenAPI.yaml. Note that this spec includes part of one of the tasks below (the new /products endpoint)
- Extend the order endpoint to find a specific order, by ID
- Extend the customer endpoint to find customers based on a query string to match a substring of one of the words in their name
- Users have complained that in production the GET endpoints can get very slow. The database is unfortunately not co-located with the application server, and there's high latency between the two. Identify if there are any optimisations that can improve performance
- Add a new endpoint /products to model products which appear in an order:
- A single order contains 1 or more products.
- A product has an ID and a description.
- Add a POST endpoint to create a product
- Add a GET endpoint to return all products, and a specific product by ID
- In both cases, also return a list of the order IDs which contain those products
- Change the orders endpoint to return a list of products contained in the order
- Implement a CI pipeline on the platform of your choice to build the project and deliver it as a Dockerized image
Assume that the project represents a production application. Think carefully about the impact on performance when implementing your changes The specifications of the tasks have been left deliberately vague. You will be required to exercise judgement about what to deliver - in a real world environment, you would clarify these points in refinement, but since this is a project to be completed without interaction, feel free to make assumptions - but be prepared to defend them when asked. There's no CI pipeline associated with this project, but in reality there would be. Consider the things that you would expect that pipeline to verify before allowing your code to be promoted Feel free to refactor the codebase if necessary. Bad choices were deliberately made when creating this project.