Skip to content

Latest commit

ย 

History

7 Commits

Folders and files

NameName
Last commit message
Last commit date
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

๐Ÿ“š Library Management System Backend

REST API built with NestJS, PostgreSQL, TypeORM, and JWT Authentication


๐Ÿ“– Overview

A Library Book Management System API built using NestJS, PostgreSQL, and TypeORM with JWT Authentication, Token Blacklist, Logout-All Sessions, and Role-Based Access Control (Admin & User).

This project demonstrates:

  • ๐Ÿ” Secure Authentication
  • ๐Ÿ‘จโ€๐Ÿ’ผ Admin & ๐Ÿ‘ค User Roles
  • ๐Ÿ“š Book CRUD Operations
  • ๐Ÿ“ก Swagger API Documentation
  • ๐Ÿงช Postman Testing
  • โš™๏ธ Config Module & Environment Variables
  • ๐Ÿงฑ Clean Backend Architecture

๐Ÿš€ Features

๐Ÿ” Authentication & Security

Feature Description
Register User account creation
Login JWT authentication
Logout Blacklist current token
Logout All Logout from all devices
Token Blacklist Stores logged out JWT tokens
Scheduler Removes expired tokens daily
Default Admin Pre-created admin account
Guards Protected routes
JWT Token-based security

๐Ÿ“š Book Management

Feature Admin User
View All Books โœ… โœ…
View Book by ID โœ… โœ…
Create Books โœ… โŒ
Update Books โœ… โŒ
Delete Books โœ… โŒ

๐Ÿ‘ฅ User Management

Feature Admin User
Register โŒ โœ…
Login โœ… โœ…
View All Users โœ… โŒ
Delete Users โœ… โŒ
Delete Admin โŒ โŒ
Logout โœ… โœ…
Logout-all โœ… โœ…

๐Ÿ› ๏ธ Tech Stack

Technology Usage
NestJS Backend Framework
PostgreSQL Database
TypeORM ORM
JWT Authentication
Swagger API Documentation
Class Validator DTO Validation
Guards Authorization
Middleware Request Handling
Interceptors Response Control
Exception Filters Error Handling
Postman API Testing
Config Module Environment Config

๐Ÿ“ Project Structure

src
โ”‚
โ”œโ”€โ”€ auth
โ”œโ”€โ”€ users
โ”œโ”€โ”€ books
โ”œโ”€โ”€ blacklist
โ”œโ”€โ”€ common
โ”‚   โ”œโ”€โ”€ guards
โ”‚   โ”œโ”€โ”€ decorators
โ”‚   โ”œโ”€โ”€ interceptors
โ”‚   โ”œโ”€โ”€ filters
โ”‚   โ”œโ”€โ”€ middleware
โ”‚
โ”œโ”€โ”€ config
โ”œโ”€โ”€ app.module.ts
โ””โ”€โ”€ main.ts

๐Ÿ”‘ Default Admin Login

Email: admin@library.com
Password: admin123

๐Ÿ“ก API Endpoints

๐Ÿ”Auth

POST /auth/register
POST /auth/login
POST /auth/logout
POST /auth/logout-all

๐Ÿ‘จ๐Ÿปโ€๐Ÿ’ปADMIN

POST   /admin/books
GET    /admin/books
GET    /admin/books/:id
PATCH  /admin/books/:id
DELETE /admin/books/:id
GET    /users
GET    /users/:id
DELETE /users/admin/:id

๐Ÿ‘คUSERS

GET    /users/books
GET    /users/books/:id

๐Ÿ“– Swagger Documentation

http://localhost:3000/api

Test all APIs directly in browser.


๐Ÿ“ฎ Postman API Collection

Use the Postman collection to test all API endpoints easily.

  1. Login as Admin
  2. Copy JWT Token
  3. Add Bearer Token in Authorization
  4. Test APIs

โš™๏ธ Installation

1๏ธโƒฃ Clone Repository

git clone https://github.com/rocky-rakesh2004/Library-management-system-backend.git

2๏ธโƒฃ Go to Project

cd Library-management-system-backend

3๏ธโƒฃ Install Dependencies

npm install

4๏ธโƒฃ Setup PostgreSQL

Create database:

library_db

5๏ธโƒฃ Create .env file

DB_HOST=localhost
DB_PORT=5432
DB_USERNAME=postgres
DB_PASSWORD=yourpassword
DB_NAME=library_db

JWT_SECRET=librarysecret
JWT_EXPIRES_IN=1d

PORT=3000

6๏ธโƒฃ Run Project

npm run start:dev

๐Ÿงช Run API

Service URL
Server http://localhost:3000
Swagger http://localhost:3000/api

๐ŸŽฏ Project Purpose

  • Learn NestJS architecture
  • Understand JWT authentication
  • Implement role-based authorization
  • Work with PostgreSQL and TypeORM
  • Build real-world backend APIs
  • Prepare for backend developer roles

๐Ÿ‘จโ€๐Ÿ’ป Author

RAKESH

GitHub: https://github.com/rocky-rakesh2004


โญ Support

If you like this project:

โญ Star the repository ๐Ÿด Fork it ๐Ÿ› ๏ธ Contribute ๐Ÿ“ฉ Share feedback


Made with โค๏ธ using NestJS

About

๐Ÿ“š Library Book Management API built using NestJS, PostgreSQL, and TypeORM with JWT Authentication and Role-Based Access Control (Admin & User). This project demonstrates a clean and scalable backend architecture with complete CRUD operations, Swagger documentation, and Postman testing support.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Packages

Contributors

Languages