LLD Design Exercise
This design exercise walks through a timed LLD session for an online auction system — bidders, items, bids, timers, and winner notification.
Introduction
This design exercise walks through a timed LLD session for an online auction system — bidders, items, bids, timers, and winner notification. Work through it as mock interview practice after completing prior modules.
Set a forty-five minute timer. Pause after each phase to compare your output with the reference approach below. Focus on process, not memorizing this exact domain.
Auctions combine concurrency (last-second bids), state (item lifecycle), and observer (outbid alerts).
Understanding the topic
Key concepts
- AuctionItem: start price, end time, current high bid.
- Bid: bidder, amount, timestamp.
- BidValidator: min increment, auction open check.
- AuctionService: placeBid, closeAuction.
- Notifier: outbid and win messages.
- Concurrent last-moment bids need synchronized accept.
sequenceDiagramClient->>ParkingLot: park(vehicle)ParkingLot->>SpotFinder: findAvailable(type)SpotFinder-->>ParkingLot: spotParkingLot->>Ticket: issue()
Step-by-step explanation
- Phase 1 (5 min): actors — seller, bidder, system; reqs — bid, auto-close, notify.
- Phase 2 (10 min): classes AuctionItem, Bid, AuctionHouse, BidService, Notifier.
- Phase 3 (10 min): sequence for placeBid validating and updating high bid.
- Phase 4 (10 min): extension — proxy bidding max amount.
- Phase 5 (10 min): trade-offs — single JVM lock vs distributed lock at scale.
- Review: SOLID, patterns used, missing edge cases.
Informative example
Reference solution core — synchronized bid acceptance:
public final class AuctionItem {private final String id;private final Money startPrice;private final Instant endsAt;private Bid highBid;public AuctionItem(String id, Money startPrice, Instant endsAt) {this.id = id;this.startPrice = startPrice;this.endsAt = endsAt;}public synchronized Optional<Bid> placeBid(Bid candidate) {if (Instant.now().isAfter(endsAt)) return Optional.empty();Money min = highBid == null ? startPrice : highBid.amount().add(Money.of(1));if (candidate.amount().compareTo(min) < 0) return Optional.empty();Bid previous = highBid;highBid = candidate;return Optional.ofNullable(previous);}public synchronized Optional<Bid> winner() {return Instant.now().isAfter(endsAt) ? Optional.ofNullable(highBid) : Optional.empty();}}public record Bid(String bidderId, Money amount, Instant at) {}public final class AuctionService {private final Map<String, AuctionItem> items = new ConcurrentHashMap<>();private final Notifier notifier;public AuctionService(Notifier notifier) { this.notifier = notifier; }public boolean bid(String itemId, Bid bid) {AuctionItem item = items.get(itemId);Optional<Bid> outbid = item.placeBid(bid);outbid.ifPresent(b -> notifier.send(b.bidderId(), "Outbid on " + itemId));return outbid.isPresent() || item != null;}}
Self-practice: redraw diagram without looking; add ProxyBidder class for extension phase.
Real-world use
Real-world applications
- Capstone mock before real interviews.
- Team internal design dojo sessions.
- Comparing student designs with reference model.
Best practices
- Time each phase strictly during practice.
- Record yourself explaining aloud.
- After session, note one SOLID win and one gap.
- Repeat weekly with different problem if auction easy.
- Peer review diagrams for coupling smells.
Common mistakes
- Skipping timer — unrealistic pacing.
- Reading solution before attempting full pass.
- No extension phase practice.
- Ignoring notify outbid requirement in reqs.
Advanced interview questions
Interview Prep
Practice concise answers, then expand each card for the explanation.
1BeginnerQuestionWhy auction as exercise?+
Answer
2BeginnerQuestionCore auction classes?+
Answer
3IntermediateQuestionHandle sniping bids at deadline?+
Answer
4IntermediateQuestionProxy bidding design?+
Answer
5AdvancedQuestionScale auctions to HLD?+
Answer
Summary
Timed auction exercise mirrors interview structure. Synchronized bid acceptance prevents lost updates. Notifier handles outbid and win events. Practice extensions: proxy bid, soft close. Compare your timed attempt to reference code.