Back to LLD explorer
Publisher / Subscriber Patterns: Observer, State

Online Auction System

Medium

Problem Summary

Design an online auction platform that handles dynamic item listings, real-time bidding, and notifications.

Functional Scope

  • Auctions transition from Created -> Active -> Completed -> Cancelled.
  • Bid validation: incoming bid must exceed current highest bid by minimum increment.
  • Broadcast updates to all active bidders when a higher bid is accepted.

Entity-Relationship (ER) Schema

AuctionItem [1] <---> [*] Bid
AuctionItem [1] <---> [*] Observer (Bidders)

Design Approach

Use synchronizations on bid actions to solve race conditions when bids arrive simultaneously in the final seconds of an auction.

Core Classes & Models

AuctionItem (ID, startingPrice, currentBid, status)Bidder (User implementation subscribing to items)AuctionController (Handles bidding state rules)
Code Blueprint
public class AuctionItem {
    private double currentHighestBid;
    public synchronized boolean placeBid(double amount) { return true; }
}