Skip to content

richmondu/shipping_application

Repository files navigation

Shipping Fee Application

Notes:

  • Python was used in this exercise instead of Java due to preference
  • But I still designed code to be clean and maintanable by utilizing OOP
  • And more importantly testing the code with unit tests and system tests as well as providing API documentation

To cover up for using Python instead of Java, I've added the following features:

  • AWS cloud for live deployment
  • Swagger for documentation and system testing
  • Jenkins CI/CD for automated build and deployment
  • Docker and Docker-Compose for containerization
  • Curl batch scripts for automated system testing

Hopefully, there are some business lines which uses Python instead of Java for specific microservices/containers such as Data Analytics related services.

Requirement

Implement API to compute a parcel cost given its weight and volume based on specific rules and conditions, including discount code from a 3rd party API.

Design

Business logic

  1. Parcel class

    • This computes the shipping cost given the item's weight and volume.
  2. Voucher class

    • This retrieves the percentage discount from a 3rd party API given a voucher code.
  3. ShippingFee class

    • This integrates both Parcel and Voucher classes to compute the discounted price.

Microservices and containerization

  1. REST API container

    • This contains the API which calls the main application business logic - ShippingFee class
  2. Nginx container

    • Nginx was used instead of AWS ELB for identical setup in local environment to cloud environment

Unit testing

  1. Run unittest.bat. This will run

    • unittest_parcel.py - test Parcel module
    • unittest_voucher.py - test Voucher module
    • unittest_shipping_fee.py - test Shipping Fee module (uses Parcel and Voucher modules)

System testing

How to test using Swagger:

  1. Go to https://app.swaggerhub.com/apis-docs/richmondu/shipping-fee_application/1.0.0

  2. Choose Server

  3. Test the API

    • Click "Try it out" button
    • Input weight, height, width and length
    • Optional: Choose code (voucher code) for discount
    • Click "Execute" button

How to test using Curl:

  1. curl -X GET "https://richmondu.com/api/v1/shipping/fee?code=random&weight=51&height=1&width=1&length=1" -H "accept: application/json"

  2. Refer to shipping_application/_curltest for batch scripts for automated system testing

    • test_curl_live.bat

    • test_curl_live_MYNT.bat

    • test_curl_live_GFI.bat

    • test_curl_live_skdlks

CI/CD

Continuous Integration and Deployment was done using Jenkins which retrieves code from my private Github repository and deploys to AWS EC2 instance

About

This is a programming interview exercise from GCash.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published