How amitkrvr/university-library works
Project type and purpose
• This is a full-stack web application built with Next.js (App Router), intended as a digital library system that lets users browse, borrow, and manage books, and lets administrators approve accounts, manage books, and view borrow records.
File structure
• Top-level directories:
• src/app – Next.js routes and layout for both public and admin areas
• src/api – Next.js serverless API routes for authentication, books, users, contact, reminders, uploads, and workflow
• src/components – reusable React components for UI and admin dashboard
• src/database – Drizzle ORM configuration, schema, migrations, seed data, Redis connection
• src/lib – client- and server-side utilities (actions, auth flows, caching, email, ratelimit)
• src/email – email templates for account approval, borrow confirmations, reminders, etc.
• Configuration and infra files:
• drizzle.config.ts & drizzle/…sql – database migration scripts
• next.config.ts, postcss.config.mjs, eslint.config.mjs – build and lint settings
• middleware.ts – Next.js middleware (e.g., auth checks, rate limiting)
Key architectural insights from README
• Standard Next.js app, uses next/font, and deploys on Vercel.
Main components and interactions
a. Frontend (Next.js App Router)
• Public UI: browse books, search, profile, contact us
• Auth flows: sign-in, sign-up (NextAuth)
• Admin UI: dashboard, account requests, book and user management
b. Backend/API (Next.js Serverless Functions)
• Authentication: NextAuth handlers under /api/auth
• CRUD endpoints: /api/books, /api/books/borrow, /api/user, /api/contact-us, /api/workflow, /api/due-reminder
• Upload auth: imagekit token generation endpoint
c. Database layer
• Relational DB (PostgreSQL or MySQL via Drizzle ORM)
• Migrations in drizzle/ and schema in src/database/schema.ts
• Redis for caching/session/ratelimiting (src/database/redis.ts)
d. External services
• Email service (via SMTP or SendGrid) for OTP, confirmations, reminders
• ImageKit for book cover uploads
• (Optional) Vercel for hosting, CDN for static assets
Architectural patterns and design principles
• File-based routing: clear split of public vs. admin under src/app
• API layer as serverless functions co-located with UI routes
• React Query (via src/lib/react-query) for client-side data fetching and caching
• Drizzle ORM for type-safe database access and migrations
• Middleware used for authentication and rate limiting
• Separation of concerns: UI components, domain actions (src/lib/actions), email templates