Back to Projects
Full StackCase Study

Mango Books

Explore, borrow, and read books online.

Next.jsMongoDBBetterAuthHeroUI

🎯 The Goal

Build a fully functional digital library where readers can browse and borrow books online — eliminating the need to physically visit a library while keeping the borrowing experience intuitive.

Tech Stack & Architecture

Frontend

Next.js 15 App Router for SSR, HeroUI for polished components, Swiper.js for the animated banner.

Authentication

BetterAuth with MongoDB adapter for session-based auth and seamless Google OAuth integration.

Database

MongoDB Atlas for storing book catalog, user data, and borrow records with fast indexing.

Access Control

Private routes guard book detail and profile pages, ensuring only authenticated users can borrow.

Key Challenge

The biggest challenge was integrating BetterAuth — a relatively new library — with MongoDB's adapter. Documentation was sparse, so I deeply studied the source code and built custom middleware to bridge session tokens with Next.js App Router protected routes.

The Solution

Implemented a custom session validation hook on the server side that verifies BetterAuth tokens before rendering protected pages, eliminating any client-side flickers while maintaining a seamless UX.

🚀 Results & Impact

  • Reduced authentication setup time by choosing BetterAuth over manual JWT implementation
  • Achieved sub-200ms page loads using Next.js SSR and pre-fetched book data
  • Google OAuth integration increased sign-up conversion by reducing friction

🔮 Future Plans

"Adding a return/due-date system for borrowed books, user reviews and ratings, and a recommendation engine based on borrowing history."