This repository holds the codebase of a packaging calculator application.
The frontend consists of an input field for the quantity and the ability to select the default pack sizes, or to enter a custom set of pack sizes (in a comma-separated format).
Once the solution is calculated a field under the button will display the set of pack sizes and their respective quantities needed to fulfill the requested order quantity.
The public frontend can be reached at: Public Frontend
The backend exposes a REST API with the following endpoints:
-
POST <url>/api/v1/packaging?quantity=<int>&packSizes=<int,int,int,...>:quantity: The total quantity of items to be packed.packSizes: A comma-separated list of available pack sizes (e.g.,1,2,3,5,10).
This endpoint returns a JSON object containing the optimal packaging solution, which includes the number of each pack size needed to fulfill the requested quantity.
-
POST <url>/api/v1/packaging?quantity=<int>:quantity: The total quantity of items to be packed. This endpoint uses the default pack sizes (250, 500, 1000, 2000, 5000) and returns a JSON object containing the optimal packaging solution.
-
GET <url>/ping: Returns{"message": "pong"}to check if the server is running.
The public API is available at: Public API
In order to run both service locally, Docker is required. Afterwards follow the steps:
-
Clone the repository:
git clone https://github.com/EvangelosSyrmos/packagingCalculator.git
-
Navigate to the project directory:
cd packagingCalculator -
Build the Docker containers
docker compose up -d
-
Access the frontend at
http://localhost:3000and the backend athttp://localhost:8080.
To run the available tests against the backend algorithm, navigate to the backend directory and run:
cd backendand then run:
go test -v ./...