How adrianhajdin/university-library-jsm works
Project Type and Purpose
• This is a full‑stack web application: “University Library Management System with Admin Panel.”
• Built in Next.js 13 (App Router) + TypeScript. It serves both public users (browse, borrow books) and admins (manage books/users, view analytics), with built‑in authentication, automated email workflows, media uploads, caching, and rate‑limiting.
File Structure
• app/
• (root): public‑facing pages (home, library, book details, profile)
• (auth): sign‑in/sign‑up flows
• admin: admin dashboard, user/book/borrow‑records pages
• api: Next.js API Routes (auth, imagekit, workflows)
• components/: shared UI controls
• lib/: business logic (actions, validations, workflows, rate‑limit)
• database/: Drizzle ORM setup, schema, migrations, seed scripts
• config files: next.config.ts, tailwind.config.ts, middleware.ts
• hooks/, styles/, constants/, types.d.ts
README for Insights
• Tech Stack: Next.js, PostgreSQL (Neon), Upstash Redis & QStash, ImageKit, Resend Emails, Drizzle ORM, Tailwind CSS, NextAuth.
• Features: authentication, book discovery, borrowing workflows (reminders & receipts), admin user/role management, analytics, caching, DDoS protection.
Main Components & Interactions
a. Client (Browser)
• Renders React pages (public & admin) via Next.js App Router.
• Calls API Endpoints for data & actions.
b. Next.js Server
• Frontend SSR/SSG and API Routes:
• /api/auth → NextAuth (session, JWT)
• /api/imagekit → media upload proxy
• /api/workflows/onboarding → QStash‑triggered jobs
• Middleware for rate‑limiting & DDoS protection.
• Business logic in lib/actions and lib/admin/actions.
• Drizzle ORM client for DB operations.
c. Persistence
• PostgreSQL (Neon) for core data (users, books, borrow records).
• Upstash Redis for caching, rate-limit counters, and QStash (message queue) for scheduling.
d. External Services
• ImageKit for media storage & optimization.
• Resend for sending emails (onboarding, reminders, PDF receipts).
• QStash for scheduled workflows (automated emails).
Interaction Flow:
1. User → Next.js UI (SSR/CSR)
2. UI → Next.js API (HTTP)
3. API → PostgreSQL (Drizzle ORM) and/or Redis
4. API → ImageKit / Resend / QStash
5. QStash → Next.js API → Resend for scheduled emails
Architectural Patterns & Principles
• Monolithic Next.js “front + back” co‑located in one codebase.
• Clear separation of route scopes: public, auth, admin.
• CQRS style: lib/actions for commands, Drizzle ORM queries for reads.
• Event‑driven workflows via QStash.
• Modular design: components, hooks, lib, database.
Essential Elements
• Route group boundaries within the Next.js container.