Back to LLD explorer
CRUD / OOD Patterns: Factory, SearchStrategy

Library Management System

Medium

Problem Summary

Design a library cataloging system tracking book stock, borrowing status, user fines, and custom search filters.

Functional Scope

  • Support books with multiple copies (each copy has a unique Barcode).
  • Search catalog by title, author, subject, or publication date.
  • Enforce maximum loan limits (e.g., 5 books for 14 days) and compute daily late fees.

Entity-Relationship (ER) Schema

Library [1] <---> [*] BookCopy
BookCopy [1] <---> [0..1] BookLending
Member [1] <---> [*] BookLending
BookCopy [1] <---> [1] Book

Design Approach

Implement search strategies using indexes on HashMaps to enable fast retrieval. Synchronize the lending action to handle concurrent checkout attempts of the last book copy.

Core Classes & Models

Book & BookLending (Book copies tracker)Member & Librarian (User actors)SearchIndex (Faceted search maps)
Code Blueprint
public class BookCopy {
    private String barcode;
    private boolean isLent;
    public synchronized void setLent(boolean status) { this.isLent = status; }
}