Skip to content

EffelZefanya/simple-library-management

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

📚 Book Management API

Made to learn implementation of REST API in Java and DTO Model Conversion.

Overview

This is a simple Spring Boot REST API for managing books, in this scenario for library.

It demonstrates clean separation of Model and DTO, validation with @Valid, and the use of H2 for the database.

Tech Stack

  • Java 17+
  • Spring Boot (Web, Validation, Data JPA)
  • Lombok (for @Data, @RestContoller, and etc.)
  • H2 Database (In-memory for testing)
  • Maven (Dependency Management)

Key Concepts Learned

Model

Part of program that represents the actual database entity. Code is here


DTO (Data Transfer Object)

A simpler version of object, used to send/receive data in API calls. It prevents exposing the full database structure and allow customizing request/response fields. Code is here

Flow of Data

Request -> Controller -> Service -> Repository -> Database and back.

Example Scenario:

  1. User sends POST /books with JSON Body
{
	"title": "The Hobbit",
    "author": "J.R. Tolkien",
    "quantity": 30
}
  1. Controller receives BookDTO (@Valid runs validation).
  2. Service converts DTO to Model
  3. Repository saves Model to DB
  4. Response is sent back as BookDTO
{
    "title": "The Hobbit",
    "author": "J.R. Tolkien",
    "quantity": 30
}

About

A Restful API for Library management where users can do CRUD methods in it.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published