Skip to content

LaizyCoder/library-app

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Library Management System

A Spring Boot MVC application for managing authors and books in a library system.

Project Overview

This application demonstrates a One-to-Many relationship between Author and Book entities. An author can write multiple books, but each book is written by a single author.

Features

  • Author Management: Create, read, and update author information
  • Book Management: Add, view, and manage books with their associated authors
  • Data Validation: Input validation using Jakarta validation constraints
  • Database Integration: MySQL database with automatic schema creation
  • JSP Views: Server-side rendered views for user interface
  • Test Coverage: Unit tests for services and repositories

Technology Stack

  • Framework: Spring Boot 3.2.3
  • Language: Java 17
  • Database: MySQL
  • ORM: Hibernate/JPA
  • View Engine: JSP with JSTL
  • Build Tool: Maven
  • Testing: JUnit 5, Mockito

Project Structure

src/
├── main/
│   ├── java/com/university/library/
│   │   ├── controller/          # Request handlers
│   │   ├── model/               # Entity classes
│   │   ├── repository/          # Data access layer
│   │   ├── service/             # Business logic
│   │   └── LibraryApplication   # Main application
│   ├── resources/
│   │   ├── application.properties
│   │   ├── data.sql            # Sample data
│   │   └── static/css/          # Stylesheets
│   └── webapp/WEB-INF/jsp/      # JSP views
└── test/
    └── java/com/university/library/
        ├── repository/          # Repository tests
        └── service/             # Service tests

Database Configuration

Update src/main/resources/application.properties:

spring.datasource.url=jdbc:mysql://localhost:3306/library_db
spring.datasource.username=root
spring.datasource.password=root

Getting Started

Prerequisites

  • Java 17 or higher
  • Maven 3.6+
  • MySQL Server

Installation & Running

  1. Clone the repository:
git clone https://github.com/LaizyCoder/library-app.git
cd library-app
  1. Build the project:
mvn clean package
  1. Run the application:
mvn spring-boot:run
  1. Access the application at: http://localhost:8080

API Endpoints

Authors

  • GET /authors - List all authors
  • GET /authors/new - Show create author form
  • POST /authors/save - Save/update author
  • GET /authors/edit/{id} - Show edit form

Books

  • GET /books - List all books with authors
  • GET /books/new - Show create book form
  • POST /books/save - Save/update book
  • GET /books/edit/{id} - Show edit form

Entity Relationships

Author Entity

  • One-to-Many with Book (cascade delete)
  • Attributes: authorId, name, email, country

Book Entity

  • Many-to-One with Author
  • Attributes: bookId, title, genre, price, publishedDate, author

Validation Rules

Author:

  • Name: Required (NotBlank)
  • Email: Required (NotBlank), Must be valid email format, Unique

Book:

  • Title: Required (NotBlank)
  • Price: Must be >= 0
  • Published Date: Required (NotNull)
  • Author: Required (NotNull)

Testing

Run tests with:

mvn test

Author

Rahul

License

MIT

About

Spring Boot MVC Application for Library Management

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors