Porter Interview Experience | SDE 2 | Oct 2024 | Bangalore
Hello,
I had got the opportunity to interview at Porter for SDE 2 position for Bangalore office in Oct 2024. Got this opportunity from naukari (not applied directly).
Previous experience: 3.7 YOE in a young company.
Round 1: Screening Round
Asked about my current and preivous work experience, Insights into my technical knowledge of java, databases, microservices.
They wanted to check if i fit there technical and functional criterion.
Round 2: DSA Round
Two DSA questions
Q1. Group anagrams: https://leetcode.com/problems/group-anagrams/description/
Q2. Word Break: https://leetcode.com/problems/word-break/description/
Able to solve both within time.
Round 3: Design Round
In my experience they had asked one of the realistic question for LLD round, where the question was not a regular question and had involved critical thinking and design skills.
Implement this system,
Imagine we have an e-commerce product - a simpler version of the Amazon app.
Current customer flow:
Customers can search and select products.
- Products can be added to the cart.
- Once added to the cart, customers can check out the products. Order placed is visible in the app with the latest status.
- Payment mode available is only offline after delivery.
Current backend systems:
- Catalog/Product Service: Manages the product life cycle, including creation and retrieval of products.
- Cart Service: Handles operations related to user carts, such as adding and removing items. Each user can have only one cart.
- Order Service: Manages order creation and updates status. It does not include a payment system, as payments are handled on delivery.
New Product Requirement:
- The product team wants to introduce a new feature - a Coupon system.
- Initially, the system should support a single coupon:
- A coupons tab will be visible in the checkout page in App which will show all the applicable coupons to the customer.
- Introducing only a single coupon - 10% discount applied to the 11th order.
- This coupon can only be used once per user, and it can be redeemed only once in a lifetime.
- The coupon should be available to the user again if the transaction fails.
The type of coupon is not limited to just discount coupon. There could be other types as well. for ex
- Get flat Rs 100 off on first order.
- Get 10% discount on order above Rs 1000
- Avail cashback of 5% upto Rs 50 on the next order.
- Get a 15% discount on SBI / HDFC / Any card.
- Buy 2 get 1 for all the shirts of some type.
Basically there can be any type of coupon which can be applied on the cart if the conditions are satisifed (like first order)
Think about the system in generic manner.
My solution after lot of discussions and even after interview
I will create a new microservice like coupon-service just like a order service. This microservice will handle CRUD ops on coupons, validate coupon, apply coupon etc.
User journey
Cart Page > Checkout > List of Coupons > Apply Coupon
Entities
1. class Coupon
String couponId
String code
Enum type: USER_LEVEL / PRODUCT_LEVEL
String description
List<Condition> conditions
List<Reward> rewards
Date lastValiditiyDate
Enum status: APPLIED, EXPIRED, AVAILABLE
2. class Condition
String conditionId
2.1 class OrderCondition extends Condition
Integer noOfOrder
2.2 class CartCondition extends Condition
Integer cartValue
2.3 class PaymentCondtion extends Condition
Card card
2.4 class ProductType extends Condition
ProductType productType
3 class Reward
String rewardId
3.1 class DiscountReward extends Reward
Integer discountPercent
Optional<Integer> uptoLimit
Enum type: FLAT / UPTO / ...
3.2 class CashbackReward extends Reward
Integer cashbackAmount
Optional<Integer> uptoLimit
3.3 class VoucherReward extends Reward
Integer voucherId
Coupon Microservice will expose some APIs
1. CRUD APIs for Coupon
2. Get List of available coupons
GET /coupons/list?cartId=?&userId=?
3. Apply coupon
POST /coupons/apply
Request Body: {
String cartId
String couponId
}
Response Body:
200 OK {
String message;
payload: {
List<Reward> rewards
}
}
400 Bad Request {
String message
}
Although the solution that i gave is still not generic and requires extension whenver any type of coupon or condition or reward comes in.
Plus, this too is a much refined solution and I thought about list of condition and rewards in coupons at the near end of interview after many hints.
Final Verdict: Rejected
Ps: If anyone have a solution (maybe better or less better) please comment, so that even i can get some more idea on it?


