/Monk-Commerce

Built a RESTful API to manage and apply different types of discount coupons (cart-wise, product-wise, and BxGy) for an e-commerce platform, with the ability to easily add new types of coupons in the future.

MONK-COMMERCE

Coupons Management API for an E-commerce Website

Built a RESTful API to manage and apply different types of discount coupons (cart-wise, product-wise, and BxGy) for an e-commerce platform, with the ability to easily add new types of coupons in the future.

Coupons Designed:

  1. Coupon Types: ● Cart-wise: Apply a discount to the entire cart if the total amount exceeds a certain threshold. ● Product-wise: Apply a discount to specific products. ● BxGy: “Buy X, Get Y” deals with a repetition limit and can be applicable to a set of products (e.g., Buy 3 of Product X or Product Y, get 1 of Product P and Product Q free and so on).
  • Note: Scheduler Implemented for expiring the coupon on weekly basis.
  1. API Endpoints: ● POST /coupons: Create a new coupon.

createCoupon

● GET /coupons: Retrieve all coupons.

getCoupons

● GET /coupons/{id}: Retrieve a specific coupon by its ID.

getCouponById

● PUT /coupons/{id}: Update a specific coupon by its ID.

updateCoupon

● DELETE /coupons/{id}: Delete a specific coupon by its ID.

● POST /applicable-coupons: Fetch all applicable coupons for a given cart and calculate the total discount that will be applied by each coupon.

fetchAllApplicableCoupons

● POST /apply-coupon/{id}: Apply a specific coupon to the cart and return the updated cart with discounted prices for each item.

applyCoupon

  1. Coupon Structure: ● Each coupon have an ID, type (cart-wise, product-wise, BxGy), discount details, and conditions etc for applicability.

ER_Diagram for Coupon

● The implementation designed to easily add new types of coupons in the future. 5. Database: ● Here MySql database used. ● Store and fetch coupon details and conditions.

  1. Error Handling: ● Implemented to handled error (e.g., coupon not found, invalid input, conditions not met).