Library Management Application

Difficulty: MEDIUMCategory: LLDFrequency: 1Asked On 2025-05-26

Problem Statement

Design and implement a Library Management System that allows members to borrow, return, and reserve books. The system should handle multiple users, books, and transactions while ensuring proper tracking of availability and fines.


Functional Requirements (FR)


User Management


•Members can register, login, and manage their profile.
•Roles: Member, Librarian, Admin.
•Librarians can add/remove books and manage inventory.


Book Management


•Add new books with metadata (title, author, ISBN, genre, publication year, copies).
•Update or delete existing book records.
•Search books by title, author, category, or ISBN.


Borrowing & Returning


•Members can borrow available books (up to a configurable limit).
•Track due dates for borrowed books.
•Return books and update availability.
•Fine calculation for overdue returns.


Reservations


•Reserve a book if it’s not currently available.
•Notify the member when the reserved book becomes available.


Transactions & Records


•Maintain borrowing history for each user.
•Generate reports for borrowed/overdue books.


Non-Functional Requirements (NFR)


•Data Consistency – Ensure accurate book availability at all times.
•Concurrency – Handle multiple users borrowing/reserving at the same time.
•Extensibility – Support e-books, digital memberships in future.
•Maintainability – Clear separation of concerns between entities.


Core Entities & Attributes


User


•userId, name, email, phone, role, borrowedBooks, reservedBooks


Book


•bookId, title, author, ISBN, genre, publicationYear, totalCopies, availableCopies


Transaction


•transactionId, bookId, userId, issueDate, dueDate, returnDate, fineAmount


Reservation


•reservationId, bookId, userId, reservationDate, status


APIs / Operations


User APIs


•registerUser(name, email, role)
•getUserDetails(userId)


Book APIs


•addBook(title, author, ISBN, totalCopies)
•searchBook(query)
•updateBook(bookId, newDetails)


Borrowing & Returning APIs


•borrowBook(userId, bookId)
•returnBook(userId, bookId)
•calculateFine(transactionId)


Reservation APIs


•reserveBook(userId, bookId)
•getReservations(userId)


LLD Design Goals


•Class diagram showing relationships between User, Book, Transaction, Reservation, Library.
•Use of design patterns where applicable:
•Singleton → for LibraryCatalog.
•Factory → for creating different types of users (Member, Librarian, Admin).
•Observer → for notifications when reserved books become available.
•Discussion of trade-offs in fine calculation, concurrency handling, and book availability.


Solution

Comments