A production-grade, full-stack Library Management System built with React (TypeScript, Vite, Tailwind CSS), Node.js/Express, Prisma ORM, MySQL, JWT Authentication, and an integrated Groq-powered AI Library Assistant.
- Framework: React 18 with TypeScript & Vite
- Styling: Tailwind CSS with Lucide Icons
- Routing: React Router v6 with Role-Based Protected Routes
- State/Notifications: Custom Context Providers (Auth, Toast, Modals)
- Runtime: Node.js (v22+ LTS)
- Server: Express.js 5
- ORM / Database: Prisma ORM with MySQL (and seamless offline in-memory fallback store)
- Authentication: JSON Web Tokens (JWT) &
bcryptjspassword hashing - Validation: Zod schemas
- AI Engine: Official Groq Cloud SDK (
groq-sdk)
Smart-Library-Management-System
├── backend/
│ ├── prisma/ # Prisma schema and database migrations
│ └── src/
│ ├── config/ # Environment configuration (JWT, ports, AI)
│ ├── constants/ # Reusable roles and messages
│ ├── middleware/ # Auth, role authorization, and error handlers
│ ├── modules/ # Modular domains:
│ │ ├── ai/ # Groq AI Assistant controller, service, routes & schema
│ │ ├── auth/ # Registration, login, profile, mapper & repo
│ │ ├── books/ # Book catalogue CRUD and inventory tracking
│ │ ├── categories/ # Category management
│ │ ├── issues/ # Issue, loan limits, return, and fine calculator
│ │ ├── librarians/ # Staff management
│ │ └── students/ # Student profile management
│ ├── prisma/ # Prisma client / mock store fallback
│ ├── utils/ # JWT, password hashing, API envelope response
│ ├── app.js # Express app registration
│ └── server.js # Standalone backend server (port 5000)
├── frontend/
│ ├── src/
│ │ ├── components/ # Reusable UI & AI Assistant Chat floating widget
│ │ ├── context/ # Auth Context & Session listeners
│ │ ├── pages/ # Dashboards (Admin, Librarian, Student), Books, Issues
│ │ ├── services/ # Typed apiClient services for each domain
│ │ └── types/ # Domain TypeScript interfaces
│ ├── index.html
│ └── vite.config.ts
├── server.js # Unified dev & production server on port 3000
├── package.json # Root workspace config (backend & frontend)
└── .env.example # Environment variable reference
Create .env at root or in backend/.env:
# Server Configuration
PORT=3000
NODE_ENV=development
# JWT Authentication
JWT_SECRET=your_long_random_jwt_secret_key_here
JWT_EXPIRES_IN=7d
# Database (MySQL via Prisma)
DATABASE_URL="mysql://root:YOUR_PASSWORD@localhost:3306/library_management_db"
# Optional Email Notification placeholders
EMAIL_USER=
EMAIL_PASS=
# AI Library Assistant (Groq Cloud Developer Tier)
AI_PROVIDER=groq
GROQ_API_KEY=your_groq_api_key_here
GROQ_MODEL=llama-3.3-70b-versatileThe SLMS AI Assistant is powered by the GroqCloud API using ultra-fast LPU inference:
- Obtain Free API Key: Sign up at https://console.groq.com/keys.
- Configure Key: Add
GROQ_API_KEY=gsk_...to your.env. - Supported Models: Default is
llama-3.3-70b-versatile. You can also configurellama-3.1-8b-instant. - Free-Tier Limits: Groq's developer tier enforces rate limits (Requests Per Minute / Tokens Per Minute). If a rate limit (HTTP 429) occurs, the assistant cleanly notifies the user, explains that the limit was reached, and offers a retry without breaking any core library operations.
- Safe Catalog Grounding: The assistant strictly answers from the real library catalog (titles, authors, categories, shelf locations, and live availability), enforcing loan limits (14 days, max 3 books) and protecting student privacy.
npm installnpm run devStarts the full-stack server on http://localhost:3000:
- Express backend APIs:
/api/auth,/api/books,/api/categories,/api/issues,/api/students,/api/librarians,/api/ai - Health check:
http://localhost:3000/health - Vite React frontend served with hot module reloading.
npm run build
npm startPre-seeded accounts are provided for testing all user roles:
| Role | Password | Permissions | |
|---|---|---|---|
| Admin | admin@smartlibrary.com |
Admin@123 |
Full system access, librarians, categories, books, issues |
| Librarian | librarian@smartlibrary.com |
Librarian@123 |
Issue books, returns, inventory, students, categories |
| Student | rahul@example.com |
Password@123 |
Browse catalog, view personal loans/fines, AI assistant |
(Quick demo login buttons are also available on the Login page).
- Frontend Typecheck & Build:
npm run build
- Linter Check:
npm run lint
- Backend Unit Tests:
npm test - AI Chat Endpoint Check (cURL):
# 1. Login to get token: TOKEN=$(curl -s -X POST http://localhost:3000/api/auth/login \ -H "Content-Type: application/json" \ -d '{"email":"admin@smartlibrary.com","password":"Admin@123"}' \ | grep -o '"token":"[^"]*' | cut -d'"' -f4) # 2. Query AI Chat endpoint: curl -X POST http://localhost:3000/api/ai/chat \ -H "Content-Type: application/json" \ -H "Authorization: Bearer $TOKEN" \ -d '{"message":"Recommend beginner programming books"}'
- Pradyum Karale
- Aditya Nadimpalli
- Vishruth Shetty
- Jay Patel