This application is designed to calculate the number of packs required to fulfill an order based on specific pack sizes. It follows the following rules:
- Only whole packs can be sent. Packs cannot be broken open.
- Within the constraints of Rule 1 above, send out no more items than necessary to fulfill the order.
- Within the constraints of Rules 1 & 2 above, send out as few packs as possible to fulfill each order.
To interact with the API, a user interface (UI) has been developed.
- Clone the repository:
git clone git@github.com:istomin10593/gimshark-test.git
cd gimshark-test
- Build Docker images and launch both the server and UI in a Docker environment:
make up
- Stop the server and UI:
make down
- Run the server on local machine:
make server-run
- Run UI on local machine:
make ui-run
The application provides an HTTP API to calculate the number of packs needed for a given order. You can interact with the API by sending a POST request to http://localhost:40999/packs with the items quantity in the request body.
Example using cURL:
curl -X POST http://localhost:40999/packs -d '{"items": 251}'
The response will be a JSON object containing the calculated packs:
'{"500":1}'
You can modify the pack sizes without changing the code. Response can be customized by adjusting the pack sizes in server/conf.yaml
.
- Open your web browser and navigate to http://localhost:40998/packs.
- Input the "Quantity of Items" and click the "Calculate Packs" button.
- You will be redirected to http://localhost:40998/packs/calculate with the resulting pack sizes displayed.
Tests are provided for server logic with pack size counting, and including both integration and unit tests. To run the tests for the server, use the following command:
make test