jnwelzel / priceyyy

Calculate cart prices using 2 separate json files: one for the cart and one for the base prices

Home Page:http://take-home-test.herokuapp.com/new-product-engineer

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Maintainability Test Coverage

Algorithm

  1. Iterate through cart items
  2. Get item data, but from the base price list
  3. Check which options are valid for this cart item using the data from the previous step and filter out the invalid options
  4. Find the base price from the base price list for each item in the cart using its options + product type as unique keys
  5. Perform price calculation using the data from both objects for each cart item

Price Calculation Formula

  • (base_price + round(base_price * artist_markup in cents)) * quantity

Architecture

  • I'm using Uncle Bob's Clean Architecture in combination with domain-driven design. Basically I'm grouping my Clean Architecture concerns (gateways, use cases, presenters, etc) by their respective domains.

How I did it

  1. Abstracted the domain problem without caring about the underlying implementation using interfaces
  2. Started working on the underlying implementations
    1. Cart item price calculator + tests
    2. Whole cart price calculator + tests
    3. Gateway that fetches the item with the base price from the JSON file + tests
  3. Implemented the CLI app + tests
    1. The AppTest can be considered an integration or end to end test since it encompasses the whole logic of the core package

Resources

How to run it

  • run mvn install
  • then either java -jar target/priceyyy-1.0.0-SNAPSHOT-jar-with-dependencies.jar <cart_file_path> <base_prices_file> or java -jar target/priceyyy-1.0.0-SNAPSHOT-jar-with-dependencies.jar for interactive mode

About

Calculate cart prices using 2 separate json files: one for the cart and one for the base prices

http://take-home-test.herokuapp.com/new-product-engineer


Languages

Language:Java 100.0%