solidcodersolidcoder
Explore Courses
solidcodersolidcoder

Practical courses for software engineering interviews — no gatekeeping, no fluff.

Company-wise Questions

  • Flipkart Machine Coding Questions

Machine Coding Tutorial

  • Machine Coding Tutorial

Explore

  • Courses
  • About
  • Privacy Policy
  • Terms

© 2026 solidcoder · Practical courses for software engineering interviews.

Built for the AI era — learn by doing.

Home/Machine Coding/Flipkart Machine Coding Questions/Ecommerce with Loyalty Program
Chapters — Flipkart Machine Coding Questions▾

Ecommerce with Loyalty Program

Machine Coding·Questions·5 min read·Sep 9, 2026

Design a gamified loyalty service for an e-commerce platform — levels, points, redemption limits, and a personalized discount engine.

Design a service that adds gamification elements to an e-commerce platform. This service tracks user transactions, letting users purchase products, redeem existing points during purchases (with constraints based on their level), and earn new points from those purchases. The service should incentivize purchases and engagement using points and levels, and be designed to stay flexible and extensible.

What the round tests

This one tests whether you can model layered business rules cleanly — levels that gate redemption limits, points that compound purchase-over-purchase, and a discount engine that stacks on top of both — without the logic turning into a pile of conditionals.

Objective

The primary objective of this project is to design and implement an in-memory loyalty service where users earn and redeem points based on their level, automatically progress between levels as points accumulate, and — as a bonus — receive a personalized discount based on purchase history.

Functional Requirements

Two tiers of scope

Requirements are split into two tiers so you know what to prioritize under time pressure: build first, and build only after the core is demoable.

Part 1 — Basic Requirements

Core functionality you must build and get working first.

1. Onboard User

Onboard a user to the platform with onboard <user_name>.

2. User Points

Earning rate by level
Level
Points per ₹100 spent
Bronze
10 points
Silver
12.5 points
Gold
15 points

Users earn points for every purchase, calculated from their level and the purchase amount, and can view their current point balance at any time.

3. User Levels

Level thresholds
Level
Accumulated points
Bronze
0 – 499 points
Silver
500 – 999 points
Gold
1000+ points

Users progress through levels automatically as points accumulate. Each level has its own benefits — redemption limits and point-earning rate.

4. Purchase Products with Points Redemption

Redemption limits by level
Level
Redemption rule
Bronze
Max 5% of the purchase amount; max 200 points redeemable.
Silver
Max 10% of the purchase amount; max 500 points redeemable.
Gold
Max 15% of the purchase amount; max 1000 points redeemable.
Redemption & earning rules

Users can redeem existing points for a portion of a purchase, choosing any amount up to what they're eligible for. They also earn points on the remaining amount paid with real money, based on their level's ₹100-to-points rate. Command shape: purchase <user_name> <order_amount> <points_to_redeem>.

5. Get User's Stats

Users can view their current level and point balance via getUserStats <user_name>.

Part 2 — Bonus Feature

Bonus — build only after the core is complete and demoable

Extensibility check — can your design layer a discount engine on top of the existing points and level logic without disturbing it.

Personalized Discount

Discount rules
Condition
Discount
More than 3 orders placed
5% discount on the current purchase.
Total spending greater than ₹10,000
10% discount on the current purchase.
Both conditions true
12% discount on the current purchase.
Discount mechanics

The discount is applied after any points redemption, and is capped at ₹5000. Once a discount is used, eligibility resets — the user again needs at least 3 orders or ₹10,000 in spend to qualify.

Example Usage: Sample Test Walkthrough

Here's a sequence of purchases for user1 that exercises point earning, level progression, redemption, and the bonus discount.

1. Bronze purchase

Input: purchase user1 800.00 0
Check
Value
Points earned
(800 / 100) × 10 = 80 points
Output: Purchase successful. Points added: 80. Total payable amount: 800.00.
Current points: 80. Current level: Bronze
Orders count: 1

2. Bronze purchase — insufficient points to redeem

Input: purchase user1 4200.00 100
Output: Purchase Failed. Not enough points to redeem

3. Bronze purchase — crosses into Silver

Input: purchase user1 4200.00 0
Check
Value
Points earned
(4200 / 100) × 10 = 420 points
Output: Purchase successful. Points added: 420. Total payable amount: 4200.00.
Current points: 500. Current level: Silver
Orders count: 2

4. Silver purchase with redemption

Input: purchase user1 3000.00 300
Check
Value
Redemption allowed
Yes — Silver max redemption is 500
Amount after redemption
3000 − 300 = 2700
Points earned
(2700 / 100) × 12.5 = 337.5 points
Output: Purchase successful. Points redeemed: 300. Points added: 337.5.
Total payable amount: 2700.00. Current points: 537.5. Current level: Silver
Orders count: 3

5. Silver purchase — crosses into Gold

Input: purchase user1 5000.00 0
Check
Value
Points earned
(5000 / 100) × 12.5 = 625.0 points
Output: Purchase successful. Points added: 625.0. Total payable amount: 5000.00.
Current points: 1162.5. Current level: Gold
Orders count: 4

6. Gold purchase with redemption and discount (bonus)

Assume user1 now qualifies for a 5% discount (orders > 3).

Input: purchase user1 12000.00 800
Check
Value
Redemption allowed
Yes — Gold max redemption is 1000
Amount after redemption
12000 − 800 = 11200
Discount
11200 × 0.05 = 560.0
Amount after discount
11200 − 560 = 10640.0
Points earned
(10640 / 100) × 15 = 1596.0 points
Output: Purchase successful. Points redeemed: 800. Points added: 1596.0.
Discount applied: ₹560.0. Total payable amount: 10640.0.
Current points: 1958.5. Current level: Gold
Orders count: 5

7. Check final stats

Input: getUserStats user1
Output: user1 has 1958.5 points. Current level: Gold.
Result

user1 progresses from Bronze to Gold purely through accumulated points, a mid-level redemption is correctly capped and validated, and the bonus discount is applied after redemption and before the final points calculation — landing at 1958.5 points and Gold level.

Guidelines

Constraints & time box

You have 90 minutes. Use only in-memory data structures — no external databases like MySQL. No UI is required; a simple driver program or test cases are enough to demo the code, but don't over-invest in input parsing. The use of Gen AI or any other code-generation tool is prohibited. Focus on the bonus feature only after the required features are complete and demoable.

Evaluation criteria
Criterion
What's assessed
Demoable & correct
Code runs and produces functionally correct output for the sample flows.
Readability
Code is easy to follow and reason about.
Entity modelling
Domain concepts (user, level, points, purchase) are modelled as proper entities, not scattered fields.
Modularity & extensibility
New levels, rules, or discount conditions can be added without rewriting the core.
Separation of concerns
Distinct responsibilities — earning, redemption, leveling, discounting — stay decoupled.
Abstractions & design patterns
Appropriate abstractions and design patterns are used where they genuinely help.
Up next1/1
Part 1 · Questions
←
← Prev Chapter
AWS S3
5 min
This month's launch price
₹30,000₹3,000SOLID50 — 50% OFF

3 years access · 40+ lessons · AI assisted coding

Enroll Now →

Use code SOLID50 at checkout

On this page
  • Objective
  • Functional Requirements
    • Part 1 — Basic Requirements
    • Part 2 — Bonus Feature
  • Example Usage: Sample Test Walkthrough
  • Guidelines