Getting Ready: Library Management System
Getting Ready: Library Management System
Why This Problem Matters
Every university, public library, and corporate research center runs a Library Management System (LMS). Software like KOHA (open-source, used in 20,000+ libraries worldwide), Ex Libris Alma, and SirsiDynix Symphony powers the daily circulation of millions of books — handling checkouts, returns, reservations, overdue fines, and catalog search.
What makes the Library Management System an excellent medium-difficulty LLD problem is the intersection of multiple design challenges in one system:
- Multiple actor types — Librarians and Members have overlapping but distinct capabilities. Modeling this cleanly requires careful use of inheritance or role-based access.
- Reservation workflows — When all copies of a book are checked out, members can reserve it. When a copy is returned, the system must notify the next member in the reservation queue. This is a textbook application of the Observer Pattern.
- Fine calculation — Overdue fines depend on the number of days past the due date and may vary by member type or book category. This is a natural fit for the Strategy Pattern.
- Catalog search — Members need to search by title, author, ISBN, or subject. Supporting multiple search strategies without hardcoding each one is another Strategy Pattern opportunity.
This problem appears frequently in LLD interviews at companies like Amazon, Google, Microsoft, and Flipkart because it tests whether candidates can model a system with multiple interacting workflows — not just a single CRUD entity.
What You'll Learn
By the end of this design problem, you will be able to:
- Model multiple actor types — design a class hierarchy where Librarians and Members share common behavior but have distinct privileges
- Design a reservation system — implement a queue-based reservation mechanism that notifies members when books become available (Observer Pattern)
- Implement fine calculation — apply the Strategy Pattern to support different fine policies without modifying core checkout logic
- Build a flexible catalog search — use the Strategy Pattern for pluggable search algorithms (by title, author, ISBN)
- Create three UML diagrams — Use Case Diagram (actor interactions), Class Diagram (structural blueprint), and Sequence Diagram (checkout flow)
- Write complete implementations in Python and Java that match the UML design exactly
- Apply and justify three design patterns — Observer, Strategy, and Iterator — explaining why each fits and what alternatives were considered
Prerequisites
Before starting this problem, make sure you're comfortable with:
- OOP Relationships — especially Composition (Book owns BookCopies) and Association (Loan references a Member) — Fundamentals S4
- Inheritance & Polymorphism — the actor hierarchy (Member, Librarian) and how method overriding enables role-specific behavior — Fundamentals S3
- Observer Pattern — how subjects notify observers of state changes (used for reservation alerts and due date reminders) — Fundamentals S12
- Strategy Pattern — how swappable algorithms avoid if/else chains (used for search and fine calculation) — Fundamentals S12
- UML Class Diagrams — reading class boxes, relationship arrows, and multiplicities — Fundamentals S5
- UML Sequence Diagrams — reading lifelines, messages, and activation bars — Fundamentals S5
If you've completed the easy design problems (DP1-DP7), you already have hands-on experience with these concepts. This problem combines them in more complex ways.
Problem Scope
We will design: The core domain logic of a Library Management System — book catalog management, member management, checkout/return circulation, reservation queuing, fine calculation, and notification triggers. All modeled as an object-oriented system with clear class hierarchies and design patterns.
We will NOT design: Database schemas, REST API endpoints, distributed systems, web UI, barcode scanning hardware integration, or inter-library loan networks. This is a Low Level Design (object-oriented) exercise, not a System Design (infrastructure) problem.
Key distinction from similar problems:
- Unlike the Car Rental System (DP12), which focuses on multi-location vehicle lifecycle, the Library System focuses on multi-copy book circulation with reservations and fines
- Unlike the Hotel Management System (DP14), which centers on room state management, the Library System centers on lending workflows with queue-based reservations