OpenBook
Problems
Tracks
How it works
Pricing
Start practicing
Sign In
Problems
/
Data Modeling
1. Library Checkout System
Medium
Model books, members and loans. Enforce loan limits, due dates and late fees.
45 minute budget
58.4% acceptance
data modeling · validation · REST
Requirements
01
POST /books, GET /books, GET /books/:id with title, author, isbn, copies.
02
POST /members with name and email. Email must be unique.
03
POST /loans checks out one copy of a book to a member. A member may hold at most 3 active loans.
04
Checking out a book with zero available copies returns 409.
05
POST /loans/:id/return marks the loan returned and computes a late fee of 50 cents per full day past the 14-day due date.
06
Requests may carry an x-now header with an ISO date. Treat it as the current time when present, so tests can control the clock.
07
GET /members/:id/loans lists active and returned loans with fees.
What the hidden tests check
Loan limit is enforced at exactly 3 active loans.
Available copies decrement on checkout and increment on return.
Late fee is rounded to cents and zero when returned on time.
Duplicate member email returns 409 with an error body.