Library Management

Level: Intermediate 30–60 min

Concepts: StateBusiness Rules

Solutions: C# | TypeScript | Python


Implement a library management system that handles book checkouts, returns, and reservations. The system should manage book inventory, track due dates, and handle various library policies.

Requirements

  1. Manage book inventory
    • Add and remove books
    • Track book status (available, checked out, reserved)
    • Handle multiple copies of the same book
    • Manage book categories and locations
  2. Handle checkouts and returns
    • Process book checkouts
    • Track due dates
    • Handle late returns
    • Calculate fines
  3. Manage reservations
    • Place and cancel reservations
    • Notify when reserved books are available
    • Handle reservation queues
    • Expire old reservations

Hint

Start by implementing the basic book management functionality, then add checkout and reservation features. Consider using a state machine to track book status. Think about:

  • Data consistency and validation
  • Concurrent access handling
  • Business rule enforcement
  • Error handling and edge cases

Bonus

The reference implementation deliberately scopes to the twenty core scenarios. The items below are stretch goals that are not modeled in the reference:

  • Implement a patron management system
  • Add support for different types of library materials
  • Create a recommendation system
  • Implement a search and filtering system
  • Add support for e-books and digital content

Reference Walkthrough

Full C#, TypeScript, and Python implementations live at tddbuddy-reference-katas/library-management. Twenty scenarios across books & copies, members, checkouts, returns, and reservations — shared across all three languages — with a Library aggregate, Book/Copy/Member/Loan/Reservation entities, Money and Isbn value types, Clock and Notifier collaborators, and three fluent builders (BookBuilder, MemberBuilder, LibraryBuilder) plus FixedClock and RecordingNotifier test doubles.

  • C# (.NET 8, xUnit, FluentAssertions) — walkthrough
  • TypeScript (Node 20, Vitest, strict types) — walkthrough
  • Python (3.11, pytest, dataclasses, Decimal) — walkthrough

This kata ships in Agent Full-Bake mode: one commit per language with the full domain design landing together. The walkthroughs read as design rationalewhy Copy is an entity rather than an available-count integer, why expireReservations() is an explicit sweep like video-club-rental’s MarkOverdueRentals, why fine calculation lives on Loan. See the repo’s Gears section for when middle gear is the right call.