Design a Multi-Branch Library Management System
Design a library platform that separates titles from physical copies and safely coordinates search, holds, pickup, borrowing, and returns across branches.
Problem statement
For this exercise, assume one public-library network manages physical titles and individually identified copies across many branches.
Patrons can search titles, inspect approximate branch availability, place one active hold for pickup at a selected branch, borrow the assigned copy at pickup, inspect the loan, and return it.
A copy can be available, held, or loaned to at most one patron at a time; concurrent hold or borrow commands must never create overlapping loans. Unclaimed holds expire after three days.
Return must atomically close the active loan and make the copy eligible for the next hold, while notification delivery is asynchronous, retryable, and never the authority for copy state. Search availability may lag, but hold, pickup, borrow, and return commands validate authoritative copy state.
Assume 5,000 branches, 50 million titles, 200 million copies, peaks of 3,000 searches and 500 lifecycle commands per second, 300 ms p95 search latency, and one second p95 command latency. Design catalog ingestion, search, per-copy lifecycle authority, holds, loans, notifications, and reconciliation.
Fines, payments, ebooks, acquisitions, inter-branch transfers, recommendations, and staff scheduling are outside scope.
What to build
- Patrons can search titles and inspect approximate physical-copy availability by branch.
- Patrons can idempotently hold one eligible copy for pickup at a selected branch, and unclaimed holds expire after three days.
- Staff can idempotently convert a patron's active hold into one durable, non-overlapping loan at pickup.
- Staff can idempotently close the active loan and transition the returned copy toward the next eligible hold, with retryable notifications.
At scale
- For this exercise, assume 5,000 branches, 50 million bibliographic titles, and 200 million individually identified physical copies.
- For this exercise, support peaks of 3,000 searches and 500 hold, pickup, borrow, or return commands per second.
- For this exercise, target 300 milliseconds p95 for search and one second p95 for an accepted lifecycle command.
- For this exercise, search availability may lag authoritative copy state by up to one minute, but a copy must never have overlapping active holds or loans.