BookWise is a full-stack university library management platform built with Next.js 15. It enables students to browse, borrow, and return books while giving administrators powerful tools to manage the library's inventory, users, and borrowing workflows β all secured with role-based authentication and rate limiting.
graph TB
subgraph "Client Layer"
Browser["π₯οΈ Browser"]
end
subgraph "Next.js 15 App Router"
direction TB
MW["π Middleware<br/>(Auth + Route Protection)"]
subgraph "Public Routes"
SI["/sign-in"]
SU["/sign-up"]
end
subgraph "User Routes"
HOME["/ (Home)"]
LIB["/library"]
BOOK["/books/[id]"]
PROF["/my-profile"]
end
subgraph "Admin Routes"
ADM["/admin"]
ADM_USERS["/admin/users"]
ADM_BOOKS["/admin/books"]
ADM_BORROW["/admin/book-requests"]
ADM_ACCT["/admin/account-requests"]
end
subgraph "API Layer"
AUTH_API["/api/auth/[...nextauth]"]
IK_API["/api/auth/imagekit"]
WF_API["/api/workflows/onboarding"]
end
end
subgraph "External Services"
DB[("π Neon PostgreSQL<br/>(Serverless)")]
REDIS[("β‘ Upstash Redis<br/>(Rate Limiting)")]
QSTASH["π¨ QStash<br/>(Email Workflows)"]
IK["πΌοΈ ImageKit<br/>(Image CDN)"]
RESEND["βοΈ Resend<br/>(Email Delivery)"]
end
Browser --> MW
MW --> SI & SU
MW --> HOME & LIB & BOOK & PROF
MW --> ADM & ADM_USERS & ADM_BOOKS & ADM_BORROW & ADM_ACCT
AUTH_API --> DB
IK_API --> IK
WF_API --> QSTASH --> RESEND
HOME --> DB
LIB --> DB
BOOK --> DB
PROF --> DB
ADM --> DB
ADM_USERS --> DB
ADM_BOOKS --> DB
ADM_BORROW --> DB
ADM_ACCT --> DB
MW --> REDIS
style Browser fill:#4B5563,color:#fff
style DB fill:#4169E1,color:#fff
style REDIS fill:#EF4444,color:#fff
style QSTASH fill:#8B5CF6,color:#fff
style IK fill:#F97316,color:#fff
style RESEND fill:#000,color:#fff
erDiagram
users {
uuid id PK "defaultRandom()"
varchar full_name
text email UK
int university_id UK
text password
text university_card
enum status "PENDING | APPROVED | REJECTED"
enum role "USER | ADMIN"
date last_activity_date
timestamp created_at
}
books {
uuid id PK "defaultRandom()"
varchar title
varchar author
text genre
int rating
text cover_url
varchar cover_color
text description
int total_copies
int available_copies
text video_url
varchar summary
timestamp created_at
}
borrow_records {
uuid id PK "defaultRandom()"
uuid user_id FK
uuid book_id FK
timestamp borrow_date
date due_date
date return_date
enum status "BORROWED | RETURNED"
timestamp created_at
}
users ||--o{ borrow_records : "borrows"
books ||--o{ borrow_records : "is borrowed"
| Feature | Description |
|---|---|
| π Authentication | Secure sign-up/sign-in with university ID verification |
| π Book Browsing | Browse the full library with search & genre filters |
| π Book Details | View book info, cover, description, and video preview |
| π Borrow Books | One-click borrowing with 7-day due dates |
| π Return Books | Easy return flow with receipt download |
| π€ Profile | View borrowed books, due dates, and borrowing history |
| π‘οΈ Rate Limiting | Protected against abuse with Upstash Redis |
| Feature | Description |
|---|---|
| π Dashboard | Stats overview: total books, users, pending approvals, active borrows |
| π Book Management | Add, edit, and delete books with cover image upload |
| π₯ User Management | Approve/reject registrations, change user roles |
| π Borrow Requests | View and manage all borrowing activity |
| β Account Requests | Review and approve pending university ID verifications |
| π¨ Custom Covers | Color picker for book cover customization |
mindmap
root((BookWise))
Frontend
Next.js 15 (App Router)
React 19
TypeScript
Tailwind CSS
Radix UI Primitives
Lucide React Icons
React Hook Form + Zod
Backend
Next.js Server Actions
Auth.js v5 (NextAuth)
Drizzle ORM
Upstash Workflow
Database
Neon PostgreSQL (Serverless)
Upstash Redis
Storage
ImageKit (Image CDN)
Email
QStash
Resend
Security
bcryptjs (Password Hashing)
Rate Limiting (Upstash)
JWT Sessions
sequenceDiagram
actor Student
participant App as BookWise App
participant Auth as Auth.js v5
participant DB as Neon PostgreSQL
participant Redis as Upstash Redis
participant Email as QStash/Resend
Note over Student,Email: Sign-Up Flow
Student->>App: Submit registration form
App->>Redis: Check rate limit
Redis-->>App: OK
App->>DB: Check existing user
DB-->>App: Not found
App->>App: Hash password (bcryptjs)
App->>DB: Insert user (PENDING status)
App->>Email: Send onboarding email
Email-->>Student: Welcome email
Note over Student,Email: Admin Approval
App->>DB: Admin approves user
DB-->>App: Status β APPROVED
Note over Student,Email: Sign-In Flow
Student->>App: Enter credentials
App->>Redis: Check rate limit
Redis-->>App: OK
App->>DB: Find user by email
DB-->>App: User found
App->>App: Verify password
App->>Auth: Create JWT session
Auth-->>Student: Set session cookie
bookwise/
βββ app/
β βββ (auth)/ # Auth pages (sign-in, sign-up)
β βββ (root)/ # Main user-facing pages
β β βββ page.tsx # Home page
β β βββ layout.tsx # Root layout with header
β β βββ error.tsx # Error boundary
β β βββ loading.tsx # Loading skeleton
β βββ admin/ # Admin dashboard & management
β β βββ page.tsx # Admin dashboard
β β βββ books/ # Book CRUD
β β βββ users/ # User management
β β βββ book-requests/ # Borrow management
β β βββ account-requests/ # Registration approvals
β βββ api/ # API routes
β β βββ auth/[...nextauth]/ # Auth.js handler
β β βββ workflows/ # Upstash workflow endpoints
β βββ books/[id]/ # Book detail page
β βββ library/ # Library browsing
β βββ my-profile/ # User profile & borrowed books
βββ components/
β βββ ui/ # Radix UI primitives
β βββ admin/ # Admin-specific components
β βββ *.tsx # Shared components
βββ database/
β βββ drizzle.ts # Drizzle DB connection
β βββ redis.ts # Upstash Redis connection
β βββ schema.ts # Database schema
βββ lib/
β βββ actions/ # Server actions (auth, book)
β βββ admin/actions/ # Admin server actions
β βββ config.ts # Environment config
β βββ ratelimit.ts # Rate limiting setup
β βββ validations.ts # Zod schemas
β βββ workflow.ts # Email workflow setup
βββ constants/ # Navigation links, sample data
βββ hooks/ # Custom React hooks
βββ public/ # Static assets
βββ styles/ # Global & admin CSS
βββ auth.ts # Auth.js configuration
βββ middleware.ts # Next.js middleware
βββ types.d.ts # TypeScript type definitions
flowchart LR
subgraph "Write Operations"
direction TB
SA["Server Actions<br/>(use server)"]
SA --> DB[(Neon PostgreSQL)]
SA --> IK[ImageKit CDN]
SA --> QS[QStash Workflows]
end
subgraph "Read Operations"
direction TB
RSC["React Server Components<br/>(async)"]
RSC --> DB
end
subgraph "Client"
direction TB
CC["Client Components<br/>(use client)"]
CC --> SA
CC --> RSC
end
style SA fill:#8B5CF6,color:#fff
style RSC fill:#06B6D4,color:#fff
style CC fill:#F97316,color:#fff
style DB fill:#4169E1,color:#fff
style IK fill:#EF4444,color:#fff
style QS fill:#10B981,color:#fff
- Node.js 18+
- npm or pnpm
- A Neon PostgreSQL database
- An Upstash Redis instance
- An ImageKit account
- A Resend API key
Create a .env.local file in the root directory:
# Database
DATABASE_URL="postgresql://..."
# Auth
AUTH_SECRET="your-auth-secret"
# ImageKit
NEXT_PUBLIC_IMAGEKIT_PUBLIC_KEY="public_..."
NEXT_PUBLIC_IMAGEKIT_URL_ENDPOINT="https://ik.imagekit.io/..."
IMAGEKIT_PRIVATE_KEY="private_..."
# Upstash
UPSTASH_REDIS_URL="https://..."
UPSTASH_REDIS_TOKEN="..."
QSTASH_URL="https://..."
QSTASH_TOKEN="..."
# Resend
RESEND_TOKEN="re_..."
# API
NEXT_PUBLIC_API_ENDPOINT="http://localhost:3000/api"
NEXT_PUBLIC_PROD_API_ENDPOINT="https://your-domain.com/api"# Clone the repository
git clone https://github.com/Script-Kitty01/bookwise.git
cd bookwise
# Install dependencies
npm install
# Generate database migrations
npm run db:generate
# Apply migrations
npm run db:migrate
# Seed the database (optional)
npm run db:seed
# Start the development server
npm run devOpen http://localhost:3000 in your browser.
| Command | Description |
|---|---|
npm run dev |
Start development server with Turbopack |
npm run build |
Build for production |
npm run start |
Start production server |
npm run lint |
Run ESLint |
npm run db:generate |
Generate Drizzle migrations |
npm run db:migrate |
Apply database migrations |
npm run db:studio |
Open Drizzle Studio (DB GUI) |
- Password Hashing: All passwords are hashed with bcryptjs (10 salt rounds)
- Rate Limiting: 5 requests per minute per IP via Upstash Redis
- JWT Sessions: Stateless authentication with Auth.js v5
- Route Protection: Middleware guards all routes except public assets
- Input Validation: Zod schemas validate all form inputs
- Role-Based Access: Separate USER and ADMIN roles with protected admin routes
Contributions are welcome! Please feel free to submit a Pull Request.
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add some amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
This project is licensed under the MIT License.
Made with β€οΈ using Next.js β’ Tailwind CSS β’ Drizzle ORM