Skip to content

Sagnik-Coder24/Library-Management-System

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

116 Commits
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸ“š Library Management System (LMS)

A comprehensive, full-stack library management solution featuring a Spring Boot REST API and a modern React frontend. This system handles book inventory, member registrations, borrowing workflows, and automated profile and cover image management.

App Screenshot App Screenshot App Screenshot

πŸš€ Features

Authentication & Security

  • JWT-based stateless authentication with token refresh mechanisms
  • OAuth2 Social Login integration for third-party providers
  • Role-Based Access Control (RBAC) with distinct permissions for Librarians and Members
  • Secure password hashing and validation

Inventory Management

  • Full CRUD operations for Books, Authors, and Genres
  • Dynamic categorization and tagging system
  • Stock level tracking and availability management
  • Author profile management with biographical information

Borrowing System

  • Comprehensive tracking of borrowed books with due dates
  • Borrowing history for members and audit trails
  • Available stock level monitoring and reservations

Book Requests

  • Member-initiated requests for new titles
  • Librarian dashboard for managing and fulfilling requests
  • Request status tracking and approval workflows

File Storage & Media Management

  • Structured local storage for Author photographs
  • Book cover image management with optimization
  • Member avatar and profile image uploads
  • Dynamic directory organization by entity type and ID

Advanced Filtering & Pagination

  • Server-side pagination with configurable page sizes
  • Multi-criteria sorting capabilities
  • Advanced filtering by genre, author, availability, and publication date
  • Search functionality with partial matching and relevance scoring

Personalized User Features

  • Wishlist management for members
  • Borrowing history with analytics
  • Personalized recommendations based on borrowing patterns
  • Reading progress tracking

πŸ› οΈ Tech Stack

Backend

Component Technology Purpose
Framework Java 21, Spring Boot 3.4.3 Core application framework
Security Spring Security, JJWT, OAuth2 Client Authentication and authorization
Data Access Spring Data JPA, PostgreSQL Object-relational mapping and database
Object Mapping ModelMapper Entity to DTO conversion
Additional Libraries Lombok, Spring AOP, Spring Validation Boilerplate reduction and cross-cutting concerns

Frontend

Component Technology Purpose
Framework React 18 with Vite Modern UI development
State Management Redux Toolkit (authSlice, bookSlice) Centralized application state
Styling Tailwind CSS Utility-first CSS framework
Routing React Router DOM Client-side navigation
HTTP Client Axios API communication

πŸ“‚ Project Structure

library-management-system/
β”œβ”€β”€ backend/                          # Spring Boot Maven Project
β”‚   β”œβ”€β”€ images/                       # Local storage for file uploads
β”‚   β”‚   β”œβ”€β”€ authors/
β”‚   β”‚   β”œβ”€β”€ books/
β”‚   β”‚   └── members/
β”‚   β”œβ”€β”€ sql-scripts/                  # Database initialization and seed data
β”‚   β”œβ”€β”€ src/main/java/
β”‚   β”‚   β”œβ”€β”€ com/lms/
β”‚   β”‚   β”‚   β”œβ”€β”€ config/              # Spring configuration classes
β”‚   β”‚   β”‚   β”œβ”€β”€ controller/          # REST API endpoints
β”‚   β”‚   β”‚   β”œβ”€β”€ service/             # Business logic layer
β”‚   β”‚   β”‚   β”œβ”€β”€ repository/          # Data access layer (Spring Data JPA)
β”‚   β”‚   β”‚   β”œβ”€β”€ entity/              # JPA entities
β”‚   β”‚   β”‚   β”œβ”€β”€ dto/                 # Data Transfer Objects
β”‚   β”‚   β”‚   β”œβ”€β”€ security/            # JWT and OAuth2 configuration
β”‚   β”‚   β”‚   β”œβ”€β”€ exception/           # Custom exception classes
β”‚   β”‚   β”‚   └── util/                # Utility classes
β”‚   β”‚   └── resources/
β”‚   β”‚       β”œβ”€β”€ application.yaml      # Spring Boot configuration
β”‚   β”‚       └── application-*.yaml    # Environment-specific configs
β”‚   └── pom.xml                       # Maven dependencies
β”‚
└── frontend/                         # React + Vite Project
    β”œβ”€β”€ public/                       # Static assets
    β”œβ”€β”€ src/
    β”‚   β”œβ”€β”€ app/
    β”‚   β”‚   β”œβ”€β”€ features/            # Redux slices and reducers
    β”‚   β”‚   β”‚   β”œβ”€β”€ authSlice.js
    β”‚   β”‚   β”‚   β”œβ”€β”€ bookSlice.js
    β”‚   β”‚   β”‚   └── ...
    β”‚   β”‚   β”œβ”€β”€ store.js             # Redux store configuration
    β”‚   β”‚   └── hooks/               # Custom Redux hooks
    β”‚   β”œβ”€β”€ components/              # Reusable React components
    β”‚   β”‚   β”œβ”€β”€ common/              # Common UI components (Nav, Footer)
    β”‚   β”‚   β”œβ”€β”€ modals/              # Modal dialogs
    β”‚   β”‚   └── cards/               # Data display cards
    β”‚   β”œβ”€β”€ pages/                   # Page-level components
    β”‚   β”œβ”€β”€ services/                # API service layer with Axios
    β”‚   β”‚   └── api.js               # Centralized API configuration
    β”‚   β”œβ”€β”€ styles/                  # Global styles and Tailwind config
    β”‚   β”œβ”€β”€ App.jsx                  # Root application component
    β”‚   └── main.jsx                 # Vite entry point
    β”œβ”€β”€ index.html                   # HTML template
    β”œβ”€β”€ vite.config.js               # Vite configuration
    β”œβ”€β”€ package.json                 # npm dependencies
    └── tailwind.config.js            # Tailwind CSS configuration

βš™οΈ Getting Started

Prerequisites

Before setting up the project, ensure you have the following installed on your system:

  • JDK 21 or higher
  • Node.js v18 or higher with npm package manager
  • PostgreSQL 12 or higher for database management
  • Git for version control

Backend Setup

Follow these steps to configure and run the Spring Boot backend application:

  1. Navigate to the backend directory:

    cd backend
  2. Update the database configuration in src/main/resources/application.yaml with your PostgreSQL credentials and connection details:

    spring:
      datasource:
        url: jdbc:postgresql://localhost:5432/lms_db
        username: your_postgres_user
        password: your_postgres_password
  3. Create the PostgreSQL database and initialize the schema using the provided SQL scripts:

    psql -U your_postgres_user -d postgres -f sql-scripts/init-db.sql
  4. Start the Spring Boot application using Maven:

    ./mvnw spring-boot:run

    The backend will be accessible at http://localhost:8080

Frontend Setup

Follow these steps to set up and run the React frontend application:

  1. Navigate to the frontend directory:

    cd frontend
  2. Install all Node.js dependencies as specified in package.json:

    npm install
  3. Configure the API endpoint in your environment variables. Create a .env file in the frontend root directory:

    VITE_API_URL=http://localhost:8080/api
    
  4. Start the Vite development server:

    npm run dev

    The frontend will be available at http://localhost:5173

πŸ”— API Endpoints (Quick Reference)

HTTP Method Endpoint Access Level Description
POST /api/auth/register Public Create a new member account with email and password
POST /api/auth/login Public Authenticate user and obtain JWT token for session
GET /api/books Member/Librarian Retrieve books with filtering, pagination, and sorting options
GET /api/books/{id} Member/Librarian Retrieve detailed information for a specific book
POST /api/books Librarian Create new book entry with cover image upload
PUT /api/books/{id} Librarian Update existing book information and metadata
DELETE /api/books/{id} Librarian Remove book from inventory
POST /api/borrow Member/Librarian Create a borrowing record with due date calculation
GET /api/borrow/history Member/Librarian Retrieve borrowing history with status filtering
PATCH /api/borrow/{id}/return Member/Librarian Mark borrowed book as returned
POST /api/bookRequest Member Submit request for new book addition
GET /api/bookRequest Librarian Retrieve pending book requests
PATCH /api/bookRequest/{id} Librarian Update book request status and mark as completed
GET /api/authors Member/Librarian List all authors with pagination
POST /api/authors Librarian Add new author with profile photo
GET /api/genres Member/Librarian Retrieve all available genres
POST /api/genres Librarian Create new genre category
POST /api/wishlist/{bookId} Member Add book to personal wishlist
GET /api/wishlist Member Retrieve member's wishlist items

Authentication

All protected endpoints require a valid JWT token in the Authorization header:

Authorization: Bearer <your_jwt_token>

πŸ–ΌοΈ Media Management

The system employs a dynamic directory structure for organizing uploaded images to prevent filename collisions and maintain clean filesystem organization across different entity types.

Directory Structure

The media storage follows this organizational pattern:

images/
β”œβ”€β”€ authors/
β”‚   └── {authorId}/
β”‚       β”œβ”€β”€ profile.jpg
β”‚       └── profile-thumbnail.jpg
β”œβ”€β”€ books/
β”‚   └── {bookId}/
β”‚       β”œβ”€β”€ cover.jpg
β”‚       └── cover-thumbnail.jpg
└── members/
    └── {memberId}/
        β”œβ”€β”€ avatar.jpg
        └── avatar-thumbnail.jpg

Image Management Best Practices

  • File Upload: Images are processed server-side to generate thumbnails for optimized loading
  • Storage Location: All uploads are stored in the /images directory relative to the application root
  • File Naming: Files are organized by entity type and ID to ensure unique paths
  • Cleanup: Implement scheduled tasks to remove orphaned images when entities are deleted
  • Validation: Image uploads are validated for file type (JPEG, PNG) and size constraints

πŸ“‹ Database Schema Overview

The system uses PostgreSQL with the following primary entities:

Core Entities

  • Users: Member and Librarian accounts with authentication details
  • Authors: Author information with biographical details and profile images
  • Books: Book inventory with genre associations and availability tracking
  • Genres: Book categorization system
  • Borrowing Records: Transaction history with dates and status tracking
  • Book Requests: Member requests for new titles with approval workflow
  • Wishlist: User's saved books for future borrowing

πŸ” Security Considerations

  • Passwords are hashed using Spring Security's bcrypt encoder
  • JWT tokens include expiration time and refresh token mechanism
  • OAuth2 integration supports secure third-party authentication
  • Role-based access control ensures proper permission enforcement
  • CORS configuration is implemented for frontend-backend communication
  • SQL injection prevention through parameterized queries (Spring Data JPA)
  • CSRF protection for state-changing operations

πŸ“ License

This project is distributed under the MIT License. See the LICENSE file for complete licensing information and terms of use.

🀝 Contributing

Contributions are welcome. Please ensure adherence to existing code style and add appropriate documentation for new features.

πŸ“ž Support

For issues, questions, or suggestions, please open an issue in the project repository or contact the development team (Me 😊).

Contributors

Languages