A robust, scalable, and type-safe backend for a Library Management System. Built with Node.js, Express, and Prisma ORM, this server handles everything from user memberships and book inventories to complex borrowing workflows and fine management.
-
Relational Data Modeling: Optimized PostgreSQL schema for Users, Memberships, Books, and Borrowing records.
-
High-Performance Caching: Integrated Redis to cache heavy endpoints (e.g., membership details, user lists), drastically reducing API response times and database load.
-
Containerized Environment: Fully dockerized setup using Docker Compose for seamless and instant local environment replication without manual installations.
-
Automated Borrowing System: Tracks due dates, return dates, and renewal counts.
-
Fine Management: Automatically manages different fine types like OVERDUE, LOST_BOOK, and DAMAGED_BOOK.
-
Role-Based Access (RBAC): Distinct logic for Admin, Librarian, and User.
-
Inventory Tracking: Detailed logs for added, removed, or damaged books.
-
Notifications & Alerts: Notification system for due reminders and system announcements.
-
Language: TypeScript
-
Framework: Express.js
-
ORM: Prisma
-
Database: PostgreSQL
-
Caching: Redis
-
Containerization: Docker & Docker Compose
-
Environment: Node.js
Since this project uses Prisma, follow these steps to sync your database:
- Configure Environment Create a .env file in the root directory and add your PostgreSQL connection string:
DATABASE_URL="postgresql://username:password@localhost:5432/library_db?schema=public"
PORT=3003- Install Dependencies
npm install- Sync Database (Migrations)
npx prisma migrate dev --name init- Generate Client
npx prisma generate- Explore via Prisma Studio
npx prisma studio npm run devAlternatively, you can run the entire project (App, Database, and Redis) using Docker Compose with just one command without any local configuration:
- Create a .env file in the root directory:
PORT=3003
POSTGRES_USER=postgres
POSTGRES_PASSWORD=your_password
POSTGRES_DB=library_management
NODE_ENV=development- Spin up everything:
docker-compose up --build npm run dev-
@prisma/client - Type-safe database client.
-
ioredis - Robust, full-featured Redis client for Node.js.
-
express - Fast and minimalist web framework.
-
http-status - Consistent HTTP response status codes.
-
dotenv - Managing environment variables.
-
typescript - For strict typing and better developer experience.
-
The project follows a modular structure for maintainability:
-
Interfaces: Data definitions and types.
-
Services: Core business logic and database interactions.
-
Controllers: Request handling and response formatting.
-
Routes: API endpoint mapping.
-
Utils: Shared utility files (Prisma & Redis Client configs).
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.