Skip to content

storm309/java-library-management-system

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

21 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Library Management System

A full-stack web application for managing a library — built with Spring Boot on the backend and React + Vite on the frontend, powered by PostgreSQL.

Modern SaaS-style UI: purple gradient sidebar, split-panel auth pages, dark mode, live stats dashboard, and full CRUD for books, authors, categories, and members.


Features

Authentication

  • Register in 2 steps: Account (name, username, email, password) → Profile (phone, address)
  • Real-time password strength hints (length, number/symbol, mixed case)
  • Login with username or email (case-insensitive)
  • Session persisted in localStorage; protected routes auto-redirect to login

Books

  • Add books with title, author, image URL, publish year, description, and categories
  • Searchable / filterable book grid with cover images and availability status
  • Borrow and Return with live status updates
  • Book detail modal with full description and metadata

Authors

  • Add authors with name and bio
  • Inline edit (name + bio) directly from the author card
  • Click an author to see all their books

Categories

  • Create and browse categories (Fiction, Science, History, etc.)
  • Books can belong to multiple categories (many-to-many)

Members

  • View all registered users with profile details
  • See which books each user currently has borrowed
  • "You" badge highlights the logged-in user

Stats Dashboard (Home)

  • Live counters: total books, available, borrowed, authors, categories, members
  • Recently added books grid (last 6)
  • My Borrowed Books panel + Quick-action shortcuts

Profile Editor

  • Edit display name, email, phone, address
  • Change password with current-password verification
  • Auto-generated avatar from initials

UI / UX

  • Dark mode toggle (persisted via data-theme on <html>)
  • Gradient purple sidebar with smooth active/hover states
  • Split-panel auth pages — white form left, blue-to-purple graphic right
  • Fully responsive; auth right panel hides on mobile
  • 100% custom CSS — no UI framework

Tech Stack

Layer Technology
Backend Java 21, Spring Boot 3.2.5, Spring Data JPA, Hibernate
Database PostgreSQL 17
Frontend React 18, Vite 5, React Router DOM v6
Styling Custom CSS design system (no framework)
Build Maven (backend), npm (frontend)

Project Structure

java-library-management-system/
├── backend/
│   └── src/main/java/com/library/
│       ├── config/          CorsConfig.java
│       ├── controller/      AuthController, BookController, AuthorController,
│       │                    CategoryController, UserController
│       ├── dto/             AuthRequest, AuthResponse, BookRequest
│       ├── entity/          User, Profile, Book, Author, Category
│       ├── repository/      UserRepository (email + username lookup)
│       ├── service/         UserService (login, register, profile update)
│       └── LibraryApplication.java
│
└── frontend/src/
    ├── api/api.js           All fetch() calls with error handling
    ├── pages/
    │   ├── Login.jsx        Split-panel, underline inputs, social buttons
    │   ├── Register.jsx     2-step, password hints, split-panel
    │   ├── Dashboard.jsx    Gradient sidebar + dark mode toggle
    │   ├── Home.jsx         Stats dashboard + recent books
    │   ├── Books.jsx        Grid + search + filter + detail modal
    │   ├── Authors.jsx      Inline edit with bio
    │   ├── Categories.jsx
    │   ├── Users.jsx        Member list with borrowed books
    │   └── Profile.jsx      Edit profile + change password
    ├── App.jsx              Routes + PrivateRoute guard
    └── index.css            Custom CSS design system

Database Relationships

User ──────── Profile      One-to-One
User ──────── Book[]       One-to-Many  (borrowed books)
Book ──────── Author       Many-to-One
Book ──────── Category[]   Many-to-Many

Tables are auto-created and migrated by Hibernate (ddl-auto=update).


API Reference

Method Endpoint Description
POST /auth/register Register new user
POST /auth/login Login with username or email
GET /books List all books
POST /books Add a book
PUT /books/{id}/borrow/{userId} Borrow a book
PUT /books/{id}/return Return a book
GET /authors List all authors
POST /authors Add an author
PUT /authors/{id} Update name + bio
GET /authors/{id}/books Books by author
GET /categories List all categories
POST /categories Add a category
GET /users List all users
GET /users/{id}/books Books borrowed by user
PUT /users/{id}/profile Update profile (name, email, phone, address, password)

How to Run

Prerequisites

  • Java 21+, Maven 3.9+, Node.js 18+, PostgreSQL 17

1. Create the database

CREATE DATABASE librarydb;

2. Start the backend

cd backend
mvn spring-boot:run

API runs at http://localhost:8080

3. Start the frontend

cd frontend
npm install     # first time only
npm run dev

App opens at http://localhost:5174

Vite proxies /api/* to http://localhost:8080 — no CORS issues in development.


Configuration

backend/src/main/resources/application.properties:

spring.datasource.url=jdbc:postgresql://localhost:5432/librarydb
spring.datasource.username=postgres
spring.datasource.password=root
spring.jpa.hibernate.ddl-auto=update
server.port=8080
server.error.include-message=always

Author

Built by storm309

About

A console-based Library Management System built using Core Java and MVC architecture. This project demonstrates OOP concepts, collections framework, and real-world book management operations.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors