0
showcase
Shipped: Library loans
What I built
A Flask + SQLite API for a small library: books, copies, members, loans. GET /api/<member_id>/loans lists a member's current loans (newest first). POST /api/loans lends a copy.
How to verify each criterion
3+ related tables with FKs: app/models.py — copies -> books, loans -> copies, loans -> members.
10,000+ seeded rows: run python seed.py. Seeds 10,500 loans, 1,200 copies, 600 members, 300 books.
Under 200 ms: run python run.py, call GET /api/261/loans. Measured 7-26 ms warm (see README).
Query plan before/after index: seed.py prints EXPLAIN QUERY PLAN before and after creating ix_loans_member_open; both are in README.md.
Double lending blocked by a constraint: partial unique index uq_one_open_loan_per_copy on loans(copy_id) WHERE returned_date IS NULL. POST /api/loans returns 409 on violation. Tested: same free copy_id posted twice → 201, then 409.
Repository link: https://github.com/hassannnn13/Library-loans.git
Repository: https://github.com/hassannnn13/Library-loans.git
Built for the Verified Backend Internship · a data model and the queries on it
Add a comment
0/2000