Back to All Projects
Featured Case Study•Full-Stack / MERN

BookNook

Full-Stack Online Library Management System with Atomic Borrowing & JWT Route Protection

BookNook Preview Banner
Technology Stack & Libraries
Next.js (App Router)TypeScriptTailwind CSSShadcn UINode.jsExpress.jsMongoDB Nativejose JWT

Architectural Overview

BookNook is an enterprise-grade library management application engineered to solve real-world book circulation and borrowing workflows. Built on the Next.js App Router and a modular Express backend, it provides seamless catalog navigation, instant regex-powered book discovery, and strict state management. The borrowing lifecycle ensures zero stock inconsistencies by applying atomic MongoDB filter updates. Protected routes leverage stateless JWT verification using the `jose` library across both client-side middleware and server endpoints.

Key Features

  • ✓Dynamic Book Cataloging: Comprehensive category navigation, genre grouping, and real-time regex search filtering.
  • ✓Atomic Borrowing Engine: Ensures race-condition prevention when stock reaches 0 using atomic MongoDB queries (`$inc: { copies: -1 }` with `{ copies: { $gt: 0 } }`).
  • ✓Interactive Borrow Modal: Custom modal dialogs with borrower verification, automated return date calculation, and instant UI state updates.
  • ✓Stateless JWT Authentication: Secure user sessions authenticated via `jose` across Next.js middleware and protected Express endpoints.
  • ✓Book Return & Replenishment: Clean return workflows that atomically increment available inventory and record borrowing histories.
Engineering Resilience

Challenges Faced While Developing the Project

Challenge 1

Preventing Inventory Race Conditions During Simultaneous Borrowing

High concurrent borrow attempts on books with 1 copy remaining risked negative inventory counts. Resolved this by swapping read-then-write updates with single atomic MongoDB operations combining an increment filter (`$inc: { copies: -1 }`) and query predicate (`copies: { $gt: 0 }`), ensuring safe and consistent concurrency.

Challenge 2

Next.js App Router Prerender ECONNREFUSED Errors

During production static build runs, dynamic pages attempted fetching from backend APIs before the server was up. Resolved this by implementing dynamic runtime segment configs (`export const dynamic = 'force-dynamic'`) and graceful fallback skeletons on SSR boundaries.

Challenge 3

Desktop Book Cover Aspect Ratio Distortion

Varying user-uploaded book cover dimensions caused erratic card heights and cropped artwork. Solved using standardized Next.js Image containers with fixed `aspect-[3/4]` ratios and CSS object-cover with padded backdrop blur.

Roadmap & Scalability

Potential Improvements & Future Plans

Phase 1

Automated Due-Date Notifications: Integration with nodemailer and cron workers for 48-hour return reminders.

Phase 2

Admin Analytics Dashboard: Real-time circulation charts, overdue tracking, and most-read genre metrics.

Phase 3

AI-Powered Book Recommendations: Vector embeddings or genre-similarity algorithms recommending next reads based on user borrowing history.