Skip to content

A modular Go application that calculates the optimal combination of packs to fulfil customer orders in millions

License

Notifications You must be signed in to change notification settings

Reaper1994/go-package-master

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

87 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

go-package-master

A modular Go application that calculates the optimal combination of packs to fulfil customer orders.

Installation

cd go-package-master
  1. Install Dependences
go mod tidy
  1. Update the config.json file if necessary to adjust pack sizes. sample config.json
  {
      "packs": [
          { "size": 250 },
          { "size": 500 },
          { "size": 1000 },
          { "size": 2000 },
          { "size": 5000 }
      ]
  }
  1. Running the Application Start the application by running:
cd cmd
go build .

API

Calculate Packs (v1) URL: /api/v1/calculate Method: POST

Request Body:

{
  "items": 12001
}

Response:

{"2000":1,"250":1,"5000":2}

Testing Run unit and feature tests using:

cd tests
go test .

Example

To test the API, you can use curl:

curl -X POST http://localhost:8080/api/v1/calculate \
  -H "Content-Type: application/json" \
  -H "Accept: application/json" \
  -H "Authorization: Bearer GSLC-123-0R" \ 
  -d '{"items": 12001}'

// Note: the authorization  token is something that ive kept as a constant for now with  value as shown above

Expected response:

{"2000":1,"250":1,"5000":2}

Considerations

  • Versioned Endpoints:
    Endpoints have been versioned to ensure backward compatibility and support for future enhancements etc.

  • Treblle SDK Integration:
    The project is integrated with the Treblle SDK for API operations and for API ops. For more details on the configuration and setup of the Treblle SDK, please refer to the relevant sections in the Dockerfile and GitHub Actions workflow..

  • GitHub Actions for CI/CD:
    The project uses GitHub Actions to automate testing, building, and deploying the Docker image to Docker Hub. This ensures a streamlined and reliable deployment process.

License MIT

About

A modular Go application that calculates the optimal combination of packs to fulfil customer orders in millions

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published