An open API service indexing awesome lists of open source software.

https://github.com/arnobt78/university-library-management-system--nextjs-fullstack

Built with Next.js, TypeScript, Postgres, the University Library Management System is a production-grade platform featuring a public-facing app and admin interface. It offers advanced functionalities like seamless book borrowing with reminders and receipts, robust user management, automated workflows, optimized tech stack for real-world scalability
https://github.com/arnobt78/university-library-management-system--nextjs-fullstack

account-request admin-dashboard admin-panel admin-profile-services analytics-dashboard borrow-book-reminder drizzle-orm imagekit library-management library-management-system library-systems nextauth nextjs-typescript-tailwindcss postgresql resend role-management shadcn university-library university-library-management upstash-qstash

Last synced: 22 days ago
JSON representation

Built with Next.js, TypeScript, Postgres, the University Library Management System is a production-grade platform featuring a public-facing app and admin interface. It offers advanced functionalities like seamless book borrowing with reminders and receipts, robust user management, automated workflows, optimized tech stack for real-world scalability

Awesome Lists containing this project

README

          

# University Library Management System - Next.js, PostgreSQL, Redis, Upstash, Resend, ImageKit FullStack Project

A modern, full-stack university library management solution built with Next.js 15, TypeScript, and Drizzle ORM. BookWise provides comprehensive book borrowing, user management, and administrative features for educational institutions.

![Screenshot 2025-09-16 at 14 52 48](https://github.com/user-attachments/assets/6e8ca29b-0aa9-468d-adcc-e6d496786140)
![Screenshot 2025-09-16 at 14 58 43](https://github.com/user-attachments/assets/b9b8237b-0e43-46f3-86c6-dcd2922a3f6f)
![Screenshot 2025-09-16 at 15 00 16](https://github.com/user-attachments/assets/20e637e9-9e76-44b7-9923-317372a02a98)
![Screenshot 2025-09-16 at 15 00 38](https://github.com/user-attachments/assets/e495275c-a7b2-45aa-bd37-cd37ca1dadf8)
![Screenshot 2025-09-16 at 15 00 50](https://github.com/user-attachments/assets/e39465de-e514-44c6-b385-29ab210717e9)
![Screenshot 2025-09-16 at 15 01 00](https://github.com/user-attachments/assets/a610b78a-bf72-4371-8f95-abc5c3bf7179)
![Screenshot 2025-09-16 at 15 02 05](https://github.com/user-attachments/assets/22a8f0bb-ac89-4ab7-a93f-630306d946a1)
![Screenshot 2025-09-16 at 15 02 23](https://github.com/user-attachments/assets/89349b88-6b62-4099-8e35-fb90056d6cf4)
![Screenshot 2025-09-16 at 15 02 38](https://github.com/user-attachments/assets/7cdd7016-dd42-4211-bcb2-7abd34caacb1)
![Screenshot 2025-09-16 at 15 02 58](https://github.com/user-attachments/assets/82ed8082-54b6-41d7-a8ab-0ff5fa59646a)
![Screenshot 2025-09-16 at 15 04 06](https://github.com/user-attachments/assets/b025b991-5495-49b1-9b6f-a8c8411e204a)
![Screenshot 2025-09-16 at 15 04 24](https://github.com/user-attachments/assets/c946f818-a44a-4d2e-ba8c-27dea921876e)
![Screenshot 2025-09-16 at 15 04 41](https://github.com/user-attachments/assets/b60521d6-4597-4ad7-a3a3-1cedf41a0d0e)
![Screenshot 2025-09-16 at 15 04 58](https://github.com/user-attachments/assets/864b1033-6aa6-420b-a6a4-7420fec78652)
![Screenshot 2025-09-16 at 15 05 09](https://github.com/user-attachments/assets/854cb805-d12a-4923-8d8a-2832f5594343)
![Screenshot 2025-09-16 at 15 05 36](https://github.com/user-attachments/assets/0eacf5a5-5b47-43cb-8c05-203aba379296)
![Screenshot 2025-09-16 at 15 05 50](https://github.com/user-attachments/assets/9d004d70-20ee-406e-8c90-047e05fabb86)
![Screenshot 2025-09-16 at 15 06 03](https://github.com/user-attachments/assets/beac954e-8ace-452c-9dac-e9518d4ccb14)
![Screenshot 2025-09-16 at 15 06 14](https://github.com/user-attachments/assets/fe312128-bd0f-427f-ac26-5ad218dc9207)
![Screenshot 2025-09-16 at 15 06 20](https://github.com/user-attachments/assets/d4d516a9-22d2-4d53-b1bf-9f777cea2906)
![Screenshot 2025-09-16 at 15 07 49](https://github.com/user-attachments/assets/c2218bb1-52d9-4705-a252-85a2287a0b27)
![Screenshot 2025-09-16 at 15 08 19](https://github.com/user-attachments/assets/0a3c6b4d-734e-4450-b322-fec62daec6f6)
![Screenshot 2025-09-16 at 15 08 38](https://github.com/user-attachments/assets/715470c5-db57-4a71-8141-f559bf82ddd1)
![Screenshot 2025-09-16 at 15 08 50](https://github.com/user-attachments/assets/3db52269-da0a-4bef-9216-8451ac2f7676)
![Screenshot 2025-09-16 at 15 09 23](https://github.com/user-attachments/assets/1548d4a8-16fc-49b4-a47d-2ea86f257f30)

---

Built with Next.js, TypeScript, Postgres, the University Library Management System is a production-grade platform featuring a public-facing app and admin interface. It offers advanced functionalities like seamless book borrowing with reminders and receipts, robust user management, automated workflows, optimized tech stack for real-world scalability.

- **Live-Demo:** [https://university-library-managment.vercel.app/](https://university-library-managment.vercel.app/)

---

## ๐Ÿš€ Features

### **Core Functionality**

- **User Authentication & Authorization** - Secure login with role-based access (USER/ADMIN)
- **Book Management** - Complete CRUD operations for library books
- **Borrowing System** - Request, approve, and track book borrows
- **User Profiles** - Personal dashboards with borrowing history
- **Review System** - Rate and review books with comments
- **Admin Dashboard** - Comprehensive administrative controls

### **Advanced Features**

- **Real-time API Monitoring** - Live system health and metrics dashboard
- **API Documentation** - Interactive Swagger-style API docs
- **Admin Request System** - Users can request admin privileges
- **Fine Management** - Automated overdue fine calculations
- **Email Notifications** - Automated reminders and notifications
- **Performance Analytics** - System performance monitoring
- **Export Functionality** - Data export for analytics and reporting

### **Technical Features**

- **Responsive Design** - Mobile-first approach with Tailwind CSS
- **Real-time Updates** - Live data updates with React Query
- **Image Management** - Cloud-based image storage with ImageKit
- **Rate Limiting** - Protection against abuse with Upstash Redis
- **Database Migrations** - Version-controlled schema changes
- **Type Safety** - Full TypeScript implementation

---

## ๐Ÿ› ๏ธ Technology Stack

### **Frontend**

- **Next.js 15** - React framework with App Router
- **TypeScript** - Type-safe JavaScript
- **Tailwind CSS** - Utility-first CSS framework
- **Shadcn/ui** - Modern component library
- **Lucide React** - Beautiful icons
- **React Hook Form** - Form management
- **Zod** - Schema validation
- **TanStack Query** - Server state management

### **Backend**

- **Next.js API Routes** - Serverless API endpoints
- **NextAuth.js** - Authentication framework
- **Drizzle ORM** - Type-safe database ORM
- **PostgreSQL** - Primary database (Neon)
- **Redis** - Caching and rate limiting (Upstash)

### **External Services**

- **ImageKit** - Image storage and optimization
- **Resend** - Email delivery service
- **Upstash** - Redis and QStash for background jobs
- **Vercel** - Deployment platform

### **Development Tools**

- **ESLint** - Code linting
- **Prettier** - Code formatting
- **Drizzle Kit** - Database migrations
- **Turbopack** - Fast development builds

---

## ๐Ÿ“ Project Structure

```bash
university-library/
โ”œโ”€โ”€ app/ # Next.js App Router
โ”‚ โ”œโ”€โ”€ (auth)/ # Authentication pages
โ”‚ โ”‚ โ”œโ”€โ”€ sign-in/
โ”‚ โ”‚ โ””โ”€โ”€ sign-up/
โ”‚ โ”œโ”€โ”€ (root)/ # Main application pages
โ”‚ โ”‚ โ”œโ”€โ”€ all-books/
โ”‚ โ”‚ โ”œโ”€โ”€ books/[id]/
โ”‚ โ”‚ โ”œโ”€โ”€ my-profile/
โ”‚ โ”‚ โ””โ”€โ”€ performance/
โ”‚ โ”œโ”€โ”€ admin/ # Admin dashboard
โ”‚ โ”‚ โ”œโ”€โ”€ books/
โ”‚ โ”‚ โ”œโ”€โ”€ users/
โ”‚ โ”‚ โ”œโ”€โ”€ book-requests/
โ”‚ โ”‚ โ””โ”€โ”€ business-insights/
โ”‚ โ”œโ”€โ”€ api/ # API endpoints
โ”‚ โ”‚ โ”œโ”€โ”€ auth/
โ”‚ โ”‚ โ”œโ”€โ”€ admin/
โ”‚ โ”‚ โ”œโ”€โ”€ reviews/
โ”‚ โ”‚ โ””โ”€โ”€ status/
โ”‚ โ”œโ”€โ”€ api-docs/ # API documentation
โ”‚ โ””โ”€โ”€ api-status/ # System monitoring
โ”œโ”€โ”€ components/ # Reusable components
โ”‚ โ”œโ”€โ”€ ui/ # Shadcn/ui components
โ”‚ โ”œโ”€โ”€ admin/ # Admin-specific components
โ”‚ โ””โ”€โ”€ [feature-components] # Feature-specific components
โ”œโ”€โ”€ database/ # Database configuration
โ”‚ โ”œโ”€โ”€ schema.ts # Drizzle schema
โ”‚ โ”œโ”€โ”€ drizzle.ts # Database connection
โ”‚ โ””โ”€โ”€ seed.ts # Database seeding
โ”œโ”€โ”€ lib/ # Utility libraries
โ”‚ โ”œโ”€โ”€ actions/ # Server actions
โ”‚ โ”œโ”€โ”€ admin/ # Admin utilities
โ”‚ โ”œโ”€โ”€ services/ # External services
โ”‚ โ””โ”€โ”€ stores/ # State management
โ”œโ”€โ”€ migrations/ # Database migrations
โ”œโ”€โ”€ public/ # Static assets
โ””โ”€โ”€ styles/ # Global styles
```

---

## ๐Ÿ—„๏ธ Database Schema

### **Core Tables**

#### **Users Table**

```typescript
export const users = pgTable("users", {
id: uuid("id").primaryKey().defaultRandom(),
fullName: varchar("full_name", { length: 255 }).notNull(),
email: text("email").notNull().unique(),
universityId: integer("university_id").notNull().unique(),
password: text("password").notNull(),
universityCard: text("university_card").notNull(),
status: STATUS_ENUM("status").default("PENDING"),
role: ROLE_ENUM("role").default("USER"),
lastActivityDate: date("last_activity_date").defaultNow(),
lastLogin: timestamp("last_login", { withTimezone: true }),
createdAt: timestamp("created_at", { withTimezone: true }).defaultNow(),
});
```

#### **Books Table**

```typescript
export const books = pgTable("books", {
id: uuid("id").primaryKey().defaultRandom(),
title: varchar("title", { length: 255 }).notNull(),
author: varchar("author", { length: 255 }).notNull(),
genre: text("genre").notNull(),
rating: integer("rating").notNull(),
coverUrl: text("cover_url").notNull(),
coverColor: varchar("cover_color", { length: 7 }).notNull(),
description: text("description").notNull(),
totalCopies: integer("total_copies").notNull().default(1),
availableCopies: integer("available_copies").notNull().default(0),
videoUrl: text("video_url").notNull(),
summary: varchar("summary").notNull(),
// Enhanced fields
isbn: varchar("isbn", { length: 20 }),
publicationYear: integer("publication_year"),
publisher: varchar("publisher", { length: 255 }),
language: varchar("language", { length: 50 }).default("English"),
pageCount: integer("page_count"),
edition: varchar("edition", { length: 50 }),
isActive: boolean("is_active").default(true).notNull(),
updatedAt: timestamp("updated_at", { withTimezone: true }).defaultNow(),
updatedBy: uuid("updated_by").references(() => users.id),
createdAt: timestamp("created_at", { withTimezone: true }).defaultNow(),
});
```

#### **Borrow Records Table**

```typescript
export const borrowRecords = pgTable("borrow_records", {
id: uuid("id").primaryKey().defaultRandom(),
userId: uuid("user_id")
.references(() => users.id)
.notNull(),
bookId: uuid("book_id")
.references(() => books.id)
.notNull(),
borrowDate: timestamp("borrow_date", { withTimezone: true })
.defaultNow()
.notNull(),
dueDate: date("due_date"),
returnDate: date("return_date"),
status: BORROW_STATUS_ENUM("status").default("BORROWED").notNull(),
// Enhanced tracking
borrowedBy: text("borrowed_by"),
returnedBy: text("returned_by"),
fineAmount: decimal("fine_amount", { precision: 10, scale: 2 }).default(
"0.00"
),
notes: text("notes"),
renewalCount: integer("renewal_count").default(0).notNull(),
lastReminderSent: timestamp("last_reminder_sent", { withTimezone: true }),
updatedAt: timestamp("updated_at", { withTimezone: true }).defaultNow(),
updatedBy: text("updated_by"),
createdAt: timestamp("created_at", { withTimezone: true }).defaultNow(),
});
```

---

## ๐Ÿ”ง Installation & Setup

### **Prerequisites**

- Node.js 18+
- PostgreSQL database (Neon recommended)
- Redis instance (Upstash recommended)

### **1. Clone the Repository**

```bash
git clone https://github.com/your-username/university-library.git
cd university-library
```

### **2. Install Dependencies**

```bash
npm install
```

### **3. Environment Variables**

Create a `.env.local` file in the root directory:

```env
# Database
DATABASE_URL="postgresql://username:password@host:port/database"

# NextAuth.js
NEXTAUTH_SECRET="your-secret-key"
NEXTAUTH_URL="http://localhost:3000"

# ImageKit Configuration
NEXT_PUBLIC_IMAGEKIT_PUBLIC_KEY="your-imagekit-public-key"
NEXT_PUBLIC_IMAGEKIT_URL_ENDPOINT="https://ik.imagekit.io/your-id"
IMAGEKIT_PRIVATE_KEY="your-imagekit-private-key"

# Upstash Redis
UPSTASH_REDIS_URL="your-redis-url"
UPSTASH_REDIS_TOKEN="your-redis-token"

# QStash (Background Jobs)
QSTASH_URL="https://qstash.upstash.io/v2"
QSTASH_TOKEN="your-qstash-token"

# Email Service (Resend)
RESEND_TOKEN="your-resend-token"

# API Endpoints
NEXT_PUBLIC_API_ENDPOINT="http://localhost:3000"
NEXT_PUBLIC_PROD_API_ENDPOINT="https://your-domain.vercel.app"

# SMTP Configuration (Optional)
SMTP_HOST="smtp.gmail.com"
SMTP_PORT="587"
SMTP_USER="your-email@gmail.com"
SMTP_PASS="your-app-password"
```

### **4. Database Setup**

```bash
# Generate migration files
npm run db:generate

# Apply migrations
npm run db:migrate

# Seed the database with sample data
npm run seed
```

### **5. Start Development Server**

```bash
npm run dev
```

Visit `http://localhost:3000` to see the application.

---

## ๐Ÿš€ Getting Started

### **Default Admin Account**

After seeding the database, you can log in with:

- **Email**: `test@admin.com`
- **Password**: `12345678`

### **User Registration**

1. Visit `/sign-up`
2. Fill in your details
3. Wait for admin approval
4. Start borrowing books!

### **Admin Functions**

1. Log in as admin
2. Visit `/admin` dashboard
3. Manage users, books, and requests
4. Monitor system performance

---

## ๐Ÿ“š API Documentation

### **Authentication Endpoints**

```typescript
POST /api/auth/signin # User login
POST /api/auth/signout # User logout
GET /api/auth/session # Get current session
```

### **Book Management**

```typescript
GET /api/books # Get all books
GET /api/books/[id] # Get book by ID
POST /api/books # Create new book (Admin)
PUT /api/books/[id] # Update book (Admin)
DELETE /api/books/[id] # Delete book (Admin)
```

### **Borrowing System**

```typescript
POST /api/borrow # Request book borrow
PUT /api/borrow/[id] # Update borrow status
DELETE /api/borrow/[id] # Cancel borrow request
```

### **Review System**

```typescript
GET /api/reviews/[bookId] # Get book reviews
POST /api/reviews/[bookId] # Create review
PUT /api/reviews/edit # Update review
DELETE /api/reviews/delete # Delete review
```

### **Admin Endpoints**

```typescript
GET /api/admin/users # Get all users
PUT /api/admin/users/[id] # Update user status
GET /api/admin/books # Get all books
POST /api/admin/books # Create book
PUT /api/admin/books/[id] # Update book
DELETE /api/admin/books/[id] # Delete book
```

### **System Monitoring**

```typescript
GET /api/status/health # Overall system health
GET /api/status/database # Database status
GET /api/status/api-server # API server status
GET /api/status/metrics # System metrics
```

---

## ๐ŸŽจ Component Architecture

### **Reusable Components**

#### **BookCard Component**

```typescript
interface BookCardProps {
book: Book;
onBorrow?: (bookId: string) => void;
onViewDetails?: (bookId: string) => void;
showBorrowButton?: boolean;
}

export const BookCard = ({ book, onBorrow, onViewDetails, showBorrowButton }: BookCardProps) => {
return (





{book.title}


{book.author}


{book.genre}




{book.rating}/5

{showBorrowButton && (
onBorrow?.(book.id)} className="mt-3">
Borrow Book

)}




);
};
```

#### **ReviewFormDialog Component**

```typescript
interface ReviewFormDialogProps {
bookId: string;
isOpen: boolean;
onClose: () => void;
onReviewSubmitted: () => void;
}

export const ReviewFormDialog = ({ bookId, isOpen, onClose, onReviewSubmitted }: ReviewFormDialogProps) => {
const [rating, setRating] = useState(0);
const [comment, setComment] = useState("");

const handleSubmit = async (e: React.FormEvent) => {
e.preventDefault();
// Submit review logic
await submitReview(bookId, rating, comment);
onReviewSubmitted();
onClose();
};

return (



Review This Book




setComment(e.target.value)}
/>

Submit Review

Cancel






);
};
```

### **Custom Hooks**

#### **usePerformance Hook**

```typescript
export const usePerformance = () => {
const [metrics, setMetrics] = useState(null);
const [isLoading, setIsLoading] = useState(true);

useEffect(() => {
const fetchMetrics = async () => {
try {
const response = await fetch("/api/status/metrics");
const data = await response.json();
setMetrics(data.metrics);
} catch (error) {
console.error("Failed to fetch metrics:", error);
} finally {
setIsLoading(false);
}
};

fetchMetrics();
const interval = setInterval(fetchMetrics, 30000); // Refresh every 30s

return () => clearInterval(interval);
}, []);

return { metrics, isLoading };
};
```

---

## ๐Ÿ” Authentication & Authorization

### **NextAuth.js Configuration**

```typescript
export const { handlers, signIn, signOut, auth } = NextAuth({
session: { strategy: "jwt" },
providers: [
CredentialsProvider({
async authorize(credentials) {
const user = await db
.select()
.from(users)
.where(eq(users.email, credentials.email))
.limit(1);

if (user.length === 0) return null;

// Password verification with salt
const [saltB64, hashB64] = user[0].password.split(":");
const salt = Uint8Array.from(Buffer.from(saltB64, "base64"));
const expectedHash = Buffer.from(hashB64, "base64");

const passwordBytes = new TextEncoder().encode(credentials.password);
const hashBuffer = sha256(concatUint8Arrays(passwordBytes, salt));
const isPasswordValid = Buffer.from(hashBuffer).equals(expectedHash);

if (!isPasswordValid) return null;

return {
id: user[0].id.toString(),
email: user[0].email,
name: user[0].fullName,
};
},
}),
],
callbacks: {
async jwt({ token, user }) {
if (user) {
token.id = user.id;
token.name = user.name;

// Update last_login timestamp
await db
.update(users)
.set({ lastLogin: new Date() })
.where(eq(users.id, user.id));
}
return token;
},
async session({ session, token }) {
if (session.user) {
session.user.id = token.id as string;
session.user.name = token.name as string;
}
return session;
},
},
});
```

### **Middleware Protection**

```typescript
export default auth((req) => {
const { nextUrl } = req;
const isLoggedIn = !!req.auth;

// Protect admin routes
if (nextUrl.pathname.startsWith("/admin")) {
if (!isLoggedIn) {
return Response.redirect(new URL("/sign-in", nextUrl));
}
// Additional admin role check can be added here
}

// Protect authenticated routes
if (nextUrl.pathname.startsWith("/my-profile")) {
if (!isLoggedIn) {
return Response.redirect(new URL("/sign-in", nextUrl));
}
}
});
```

---

## ๐Ÿ“Š Real-time Monitoring

### **System Health Dashboard**

The application includes a comprehensive monitoring system accessible at `/api-status`:

#### **Service Status Monitoring**

- **API Server** - Response time and uptime tracking
- **Database** - Connection pool and query performance
- **File Storage** - ImageKit CDN status
- **Authentication** - NextAuth.js service health
- **Email Service** - SMTP configuration status
- **External APIs** - Third-party service monitoring

#### **System Metrics**

- **Database Performance** - Active connections and pool status
- **API Performance** - Requests per minute tracking
- **Error Rate** - Failed request percentage
- **Storage Usage** - Database storage consumption
- **Active Users** - Currently online users
- **SSL Certificate** - Certificate validity and expiration

### **API Documentation**

Interactive API documentation is available at `/api-docs` with:

- Complete endpoint listings
- Request/response examples
- Authentication requirements
- Interactive testing capabilities

---

## ๐ŸŽฏ Key Features Deep Dive

### **1. Book Borrowing System**

```typescript
// Request a book borrow
const borrowBook = async (bookId: string, userId: string) => {
const borrowRecord = await db.insert(borrowRecords).values({
userId,
bookId,
status: "PENDING",
borrowDate: new Date(),
});

// Send notification to admin
await sendBorrowRequestNotification(bookId, userId);

return borrowRecord;
};

// Admin approval process
const approveBorrowRequest = async (borrowId: string, dueDate: Date) => {
await db
.update(borrowRecords)
.set({
status: "BORROWED",
dueDate,
updatedAt: new Date(),
})
.where(eq(borrowRecords.id, borrowId));

// Update book availability
await updateBookAvailability(borrowId);
};
```

### **2. Review System**

```typescript
// Submit a book review
const submitReview = async (
bookId: string,
userId: string,
rating: number,
comment: string
) => {
const review = await db.insert(bookReviews).values({
bookId,
userId,
rating,
comment,
});

// Update book average rating
await updateBookRating(bookId);

return review;
};

// Calculate average rating
const updateBookRating = async (bookId: string) => {
const reviews = await db
.select({ rating: bookReviews.rating })
.from(bookReviews)
.where(eq(bookReviews.bookId, bookId));

const averageRating =
reviews.reduce((sum, r) => sum + r.rating, 0) / reviews.length;

await db
.update(books)
.set({ rating: Math.round(averageRating) })
.where(eq(books.id, bookId));
};
```

### **3. Admin Request System**

```typescript
// Request admin privileges
const createAdminRequest = async (userId: string, reason: string) => {
const request = await db.insert(adminRequests).values({
userId,
requestReason: reason,
status: "PENDING",
});

// Notify existing admins
await notifyAdminsOfNewRequest(request);

return request;
};

// Approve admin request
const approveAdminRequest = async (requestId: string, reviewedBy: string) => {
const request = await db
.select()
.from(adminRequests)
.where(eq(adminRequests.id, requestId))
.limit(1);

if (request.length === 0) return;

// Update request status
await db
.update(adminRequests)
.set({
status: "APPROVED",
reviewedBy,
reviewedAt: new Date(),
})
.where(eq(adminRequests.id, requestId));

// Grant admin role
await db
.update(users)
.set({ role: "ADMIN" })
.where(eq(users.id, request[0].userId));
};
```

---

## ๐Ÿš€ Deployment

### **Vercel Deployment**

1. Connect your GitHub repository to Vercel
2. Set environment variables in Vercel dashboard
3. Deploy automatically on push to main branch

### **Environment Variables for Production**

```env
# Production Database
DATABASE_URL="postgresql://username:password@host:port/database"

# Production URLs
NEXTAUTH_URL="https://your-domain.vercel.app"
NEXT_PUBLIC_PROD_API_ENDPOINT="https://your-domain.vercel.app"

# Production Services
NEXT_PUBLIC_IMAGEKIT_URL_ENDPOINT="https://ik.imagekit.io/your-id"
UPSTASH_REDIS_URL="your-production-redis-url"
RESEND_TOKEN="your-production-resend-token"
```

### **Database Migration in Production**

```bash
# Generate production migration
npm run db:generate

# Apply to production database
npm run db:migrate
```

---

## ๐Ÿงช Testing

### **Running Tests**

```bash
# Run all tests
npm test

# Run tests in watch mode
npm run test:watch

# Run tests with coverage
npm run test:coverage
```

### **Test Structure**

```bash
__tests__/
โ”œโ”€โ”€ components/ # Component tests
โ”œโ”€โ”€ pages/ # Page tests
โ”œโ”€โ”€ api/ # API endpoint tests
โ””โ”€โ”€ utils/ # Utility function tests
```

---

## ๐Ÿ“ˆ Performance Optimization

### **Database Optimization**

- **Indexes** - Strategic indexing on frequently queried columns
- **Connection Pooling** - Efficient database connection management
- **Query Optimization** - Optimized Drizzle ORM queries

### **Frontend Optimization**

- **Code Splitting** - Automatic route-based code splitting
- **Image Optimization** - Next.js Image component with ImageKit
- **Caching** - React Query for server state caching
- **Bundle Analysis** - Regular bundle size monitoring

### **API Optimization**

- **Rate Limiting** - Upstash Redis for API protection
- **Response Caching** - Strategic caching of API responses
- **Background Jobs** - QStash for non-blocking operations

---

## ๐Ÿ”ง Customization Guide

### **Adding New Features**

#### **1. Create New Database Table**

```typescript
// database/schema.ts
export const newTable = pgTable("new_table", {
id: uuid("id").primaryKey().defaultRandom(),
name: varchar("name", { length: 255 }).notNull(),
createdAt: timestamp("created_at", { withTimezone: true }).defaultNow(),
});
```

#### **2. Generate Migration**

```bash
npm run db:generate
npm run db:migrate
```

#### **3. Create API Endpoints**

```typescript
// app/api/new-feature/route.ts
export async function GET() {
const data = await db.select().from(newTable);
return NextResponse.json(data);
}

export async function POST(request: NextRequest) {
const body = await request.json();
const result = await db.insert(newTable).values(body);
return NextResponse.json(result);
}
```

#### **4. Create Components**

```typescript
// components/NewFeatureComponent.tsx
export const NewFeatureComponent = () => {
const [data, setData] = useState([]);

useEffect(() => {
fetch('/api/new-feature')
.then(res => res.json())
.then(setData);
}, []);

return (


{data.map(item => (
{item.name}

))}

);
};
```

### **Styling Customization**

```typescript
// tailwind.config.ts
module.exports = {
theme: {
extend: {
colors: {
primary: {
50: "#eff6ff",
500: "#3b82f6",
900: "#1e3a8a",
},
},
fontFamily: {
sans: ["Inter", "system-ui", "sans-serif"],
},
},
},
};
```

---

## ๐Ÿค Contributing

### **Development Workflow**

1. Fork the repository
2. Create a feature branch: `git checkout -b feature/new-feature`
3. Make your changes
4. Run tests: `npm test`
5. Commit changes: `git commit -m 'Add new feature'`
6. Push to branch: `git push origin feature/new-feature`
7. Create a Pull Request

### **Code Standards**

- Use TypeScript for all new code
- Follow ESLint configuration
- Write tests for new features
- Update documentation as needed
- Use conventional commit messages

### **Pull Request Guidelines**

- Clear description of changes
- Reference related issues
- Include screenshots for UI changes
- Ensure all tests pass
- Update README if needed

---

## ๐Ÿ“ License

This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.

---

## ๐Ÿ™ Acknowledgments

- **Next.js Team** - For the amazing React framework
- **Drizzle Team** - For the excellent TypeScript ORM
- **Shadcn/ui** - For beautiful component library
- **Vercel** - For seamless deployment platform
- **Neon** - For PostgreSQL hosting
- **Upstash** - For Redis and background jobs
- **ImageKit** - For image optimization
- **Resend** - For email delivery

---

## ๐Ÿ“ž Support

### **Getting Help**

- ๐Ÿ“ง Email:
- ๐ŸŒ Portfolio: [https://arnob-mahmud.vercel.app/](https://arnob-mahmud.vercel.app/)
- ๐Ÿ› Issues: [GitHub Issues](https://github.com/your-username/university-library/issues)

### **Documentation**

- ๐Ÿ“š [Next.js Documentation](https://nextjs.org/docs)
- ๐Ÿ—„๏ธ [Drizzle ORM Documentation](https://orm.drizzle.team/)
- ๐ŸŽจ [Tailwind CSS Documentation](https://tailwindcss.com/docs)
- ๐Ÿ” [NextAuth.js Documentation](https://next-auth.js.org/)

---

## ๐ŸŽฏ Roadmap

### **Upcoming Features**

- [ ] **Mobile App** - React Native mobile application
- [ ] **Advanced Analytics** - Detailed usage analytics
- [ ] **Multi-language Support** - Internationalization
- [ ] **Advanced Search** - Full-text search with filters
- [ ] **Notification System** - Real-time push notifications
- [ ] **Integration APIs** - Third-party library system integration
- [ ] **Automated Testing** - Comprehensive test suite
- [ ] **Performance Monitoring** - Advanced APM integration

### **Technical Improvements**

- [ ] **GraphQL API** - Alternative to REST API
- [ ] **Microservices** - Service-oriented architecture
- [ ] **Docker Support** - Containerization
- [ ] **CI/CD Pipeline** - Automated deployment
- [ ] **Security Audit** - Comprehensive security review

---

## Happy Coding! ๐ŸŽ‰

Free to use this project repository and extend this project further!

If you have any questions or want to share your work, reach out via GitHub or my portfolio at [https://arnob-mahmud.vercel.app/](https://arnob-mahmud.vercel.app/).

**Enjoy building and learning!** ๐Ÿš€

Thank you! ๐Ÿ˜Š

---