Design a Billing System (LLD Variant)
Problem Statement
Design the Low-Level Design (LLD) of a Billing System used by a retail store (like a supermarket, e-commerce platform, or POS terminal).
The system should support itemized billing, discounts, tax calculation, and multiple payment modes, while keeping the design modular, extensible, and easy to maintain.
The focus is on designing classes, interactions, and responsibilities, not UI or database aspects.
🎯 Goal
Design a Billing System that can:
✅ Functional Requirements
1. Cart and Items
2. Discount Handling
3. Tax Calculation
Example:
4. Billing and Payment
Compute:
5. Invoice Generation
⚙️ Non-Functional Requirements
🧱 Key Classes to Design
ClassResponsibility
Item
Represents a product with name, price, quantity, and tax category.
Tax
Represents tax percentage and logic to compute tax per item.
Discount
Base class/interface for different discount types.
BillItem
Wraps an Item with applied discounts and computed totals.
Bill
Represents the overall bill — list of items, discounts, totals, payment info.
Payment
Handles payment processing for a bill.
InvoiceGenerator
Creates the printable/digital bill summary.
BillingService / BillCalculator
Applies discounts, taxes, and computes final total.
🧩 Suggested Class Structure
1
2Bill
3 ├── List<BillItem> billItems
4 ├── double subTotal
5 ├── double discountTotal
6 ├── double taxTotal
7 ├── double grandTotal
8 ├── Payment payment
9 ├── BillStatus status (PENDING, PAID, CANCELLED)
10
11BillItem
12 ├── Item item
13 ├── double quantity
14 ├── double discountedPrice
15 ├── double taxAmount
16 ├── double totalPrice
17
18Item
19 ├── String id
20 ├── String name
21 ├── double unitPrice
22 ├── Category category
23
24Discount (abstract)
25 ├── double apply(Bill bill)
26
27FlatDiscount, PercentageDiscount, BOGODiscount
28 ├── override apply() with specific rules
29
30Tax
31 ├── double rate
32 ├── double calculate(double amount)
33
34Payment
35 ├── PaymentType type (CASH, CARD, WALLET)
36 ├── double amountPaid
37 ├── PaymentStatus status (SUCCESS, FAILED)
38
39InvoiceGenerator
40 ├── String generateInvoice(Bill bill)🔄 Flow Example
Subtotal = ₹130
After discount = ₹117
Total = ₹122.85
1
2----------------------------
3SuperMart Bill
4Items:
5Milk (2) ₹100
6Bread (1) ₹30
7Discount -₹13
8Tax (5%) ₹5.85
9----------------------------
10Total: ₹122.85
11Payment: UPI (Success)
12----------------------------🧠 Design Patterns
⚡ Possible Extensions
✅ Final Summary:
Design a Billing System (LLD) that: