Gift Card Design
Problem Statement
Design the core low-level design (LLD) of a Gift Card system that allows users to create, activate, redeem, and manage gift cards.
The system should handle balance tracking, expiry validation, and transaction logging.
🧠 Functional Requirements
Create Gift Card
Activate / Deactivate Gift Card
Check Balance
Redeem Gift Card
Reload / Top-up Gift Card (Optional)
Expiry Handling
Transaction History
🚫 Non-Functional Requirements
🧱 Suggested Classes
ClassResponsibility
GiftCard
Represents a single gift card with ID, balance, status, and expiry date.
GiftCardManager
Manages card creation, lookup, redemption, reload, and balance queries.
Transaction
Represents a single operation (redeem/reload/check) with timestamp and amount.
CardStatus (Enum)
Enum with values like ACTIVE, INACTIVE, EXPIRED, BLOCKED.
TransactionType (Enum)
Enum with values like REDEEM, RELOAD, CHECK_BALANCE.
GiftCardStore
In-memory repository or map of all cards (e.g., Map<String, GiftCard>).
🔄 Example Flow
1
2card = GiftCardManager.createCard(1000, expiry=2026-12-31)Output:
1
2Gift Card created: ID=GC1234, Balance=1000, Status=ACTIVE
2. Redeem
1
2GiftCardManager.redeem("GC1234", 200)Output:
1
2Redeemed ₹200. Remaining balance: ₹8003.Check Balance
1
2GiftCardManager.getBalance("GC1234")Output:
1
2Balance: ₹8004.Expiry Handling
🧪 Example Input / Output
Input:
1
2createCard(500)
3redeem("GC001", 200)
4redeem("GC001", 400)Output:
1
2Gift Card GC001 created with ₹500
3Redeemed ₹200 → Remaining balance ₹300
4Redemption failed: Insufficient balance⚙️ Constraints
🎯 Goals
Your LLD should:
✅ In short:
Design a modular, object-oriented Gift Card system that can create, activate, redeem, and track gift cards while ensuring accurate balance and expiry management.