Skip to content

Simple Library Management API using Spring Boot

Notifications You must be signed in to change notification settings

KokonutGamer/libman-api

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

40 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Library Management API built using Java Spring Boot

About this project

Libman is a basic REST API built using Spring Web, Spring Data Java Persistence API (JPA), and H2 Database

  • Spring Data JPA: provides a standardized way to manage relational data in Java applications
  • Spring Web: creates document-driven web services and facilitates contract-first Simple Object Access Protocol (SOAP) service development
  • H2 Database: supports CRUD operations with data stored in an embedded, open-source, in-memory database

API Endpoints

GET

  • Book
    • by ID

POST

  • Book
    • with title and author

PUT

  • Book
    • by ID

DELETE

  • Book
    • by ID

Warning

This version of the API (0.0.1-SNAPSHOT) is not considered to be a RESTful service yet.

Todo list

  • Add a new field(s) to the Book entity, such as pages, date published, volume, and edition
  • Update POST methods to return a proper response
  • Update PUT methods to return a proper response
  • Update DELETE methods to return a proper response
  • Incorporate Lombok to reduce boilerplate on entities
  • Update the Book entity to handle different states, such as available, on hold, and unavailable
  • Change the Book entity BookStatus field to a numerical field with available copies
  • Change BookController structure to handle links with different states
  • Build new controllers implementing Hypermedia as the Engine of Application State (HATEOAS)
  • Add support for new entities such as User and/or Librarian
  • Add JWT-based authentication in-memory
  • Implement Spring Security to handle requests from different roles, such as:
    • ADMIN: manages users (CRUD operations)
    • LIBRARIAN: manages books (CRUD operations), mark books as returned, update holds, flag users
    • USER: borrow, hold, renew books

Caution

The User entity uses annotations from both @Entity (jakarta.persistence.Entity) and @Data (lombok.Data). This may result in conflicts between Lombok's creation of getters and setters along with Hibernate's @UpdateTimestamp. Check this StackOverflow post again in case a breaking change occurs.

  • Uniform interface
  • Client-server
  • Stateless
  • Cacheable
  • Layered system
  • Code on demand

Example Requests

  • Register a user: curl -H "Content-Type: application/json" -d '{"email": "[email protected]", "password": "ILoveKokomi", "username": "Koi Fish"}' localhost:8080/api/v1/signup
  • Login using an existing user's account information: curl -H "Content-Type: application/json" -d '{"email": "[email protected]", "password": "ILoveKokomi"}' localhost:8080/api/v1/login

About

Simple Library Management API using Spring Boot

Resources

Stars

Watchers

Forks

Languages