Technical challenge for Consumer Team engineering candidates
If you have any questions during the challenge you can drop an email to the developer/s that introduced the challenge to you.
nate is a universal shopping experience that is designed to purchase any online product on behalf of a user.
The challenge is different for full-stack and backend candidates.
Before working on the challenge, please fork this repositoy. Add your solution to your fork.
- Create an endpoint in the API to purchase a product with a certain ID
- Use
lib/purchase-api.ts
to execute a purchase
- Use
- Design a risk assessment flow that would execute after a product has been purchased (see src/risk.ts) with provided
lib/risk-api.ts
functions andlib/action-api.ts
actions- Assume that more than 1 missed payment should reject the purchase
- The balance should cover the cost of the product and reject otherwise
- The risk score should be less than 80 to accept, above 90 to reject, and anything in-between should be flagged
- The solution should include automated tests
- The code should be readable, well-factored, and easily testable
- Implement web app functionality to fetch product data from
/products
endpoint and display to the user - Create a purchase product endpoint in the API
- Add some UI for products to execute a purchase using the new endpoint
- Refactor code & add some unit tests (web app & API)
A seamless purchase experience is a crucial part of our platform, and it involves a few important objects:
User
: the person purchasing a product through nate
userId
(string
): uniquely identifies aUser
- Other data about a user (email, billing address, etc) can be ignored for this exercise
Product
: an item that can be purchased at an online shop
productId
(string
): uniquely identifies aProduct
productUrl
(string
): the URL that is used to access the product page on the webproductPrice
(number
): the price of a product (it can be assumed that this includes any taxes or fees)discountCode
(optionalstring
): a code that can be used on checkout to apply a discount
Purchase
: an entity representing a User
buying a Product
through nate
purchaseId
(string
): uniquely identifies aPurchase
paymentMethodId
(string
): a reference to a user's payment method they are using for the purchasestatus
(success | merchant-rejected | charge-failed | invalid-details | pending | rejected
): the status of a purchase in nate's systemssuccess
: indicates that the product was purchased successfully for the usermerchant-rejected
: indicates that the merchant rejected this purchase because of issues on their endcharge-failed
: indicates that the payment method was rejected when checking outinvalid-details
: indicates that the details for the purchase are invalidpending
: indicates that we have not yet started any process against the purchaserejected
: indicates that we have rejected the purchase and will not complete it
Sometimes, people behave in a fraudulent manner. There are lots of ways this can happen, and it's business-critical for nate to evaluate purchase risk before going through and buying something on behalf of a user.
When a risk assessment is performed, the possible outcomes are:
accepted
: the risk level is low enough to proceed with the purchaserejected
: the risk level is too high for this purchaseflagged_for_review
: the risk level is uncertain, and this purchase should be reviewed manually
api
: server application that allows callers to interact with nate's systemssrc
: source code for the serverindex.ts
: the server entrypointrisk.ts
: source code for risk-related functionalitylib
: external libraries & APIs that provide useful functionality for the business - note that these APIs are asynchronous and should not be modifiedpurchase-api.ts
: an interface for executing a purchaserisk-api.ts
: a collection of interfaces for providing risk-related data about a user or payment methodaction-api.ts
: a collection of interfaces for accepting, rejecting, or flagging a purchase after risk assessment