Skip to content

Open Source Library Management System API using Spring Boot.

License

Notifications You must be signed in to change notification settings

moamenhady/library-api

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Library Management System API

This is a RESTful API for a Library Management System developed using Spring Boot, Spring Data JPA, Spring Security, and PostgreSQL.

Table of Contents

Features

  • Create, read, update, and delete books, patrons and borrows.
  • User authentication using Basic Authentication.
  • Secure password storage using Bcrypt.
  • Persistent storage of blog data in a PostgreSQL database.

Getting Started

Prerequisites

Make sure you have the following installed on your machine:

Installation

  1. Clone the repository:

    git clone https://github.com/moamenhady/library-api.git
  2. Build the project using Maven:

    cd library-api
    mvn clean install

Configuration

  1. Configure the database connection in src/main/resources/application.yml:

     datasource:
         url: jdbc:postgresql://localhost:5432/your_database
         username: your_username
         password: your_password
  2. Configure other properties as needed (e.g., server port, logging).

Usage

java -jar target/library-api-1.0.0.jar

Access the API at http://localhost:8080/

API Endpoints

A default admin user with username admin and password admin is created in the databse on application run.

Patrons:

  • GET /api/patrons : Retrieve a list of all patrons. (Requires admin authentication)
  • GET /api/patrons/{id} : Retrieve details of a specific patron by ID. (Requires admin authentication)
  • POST /api/patrons : Add a new patron to the system. (Requires no authentication - any one can signup as a patron)
  • PUT /api/patrons/{id} : Update an existing patron's information. (Requires admin authentication)
  • DELETE /api/patrons/{id} : Remove a patron from the system. (Requires admin authentication)

Books:

  • GET /api/books : Retrieve a list of all books. (Requires no authentication)
  • GET /api/books/{id} : Retrieve details of a specific book by ID. (Requires no authentication)
  • POST /api/books : Add a new book to the library. (Requires admin authentication)
  • PUT /api/books/{id} : Update an existing book's information. (Requires admin authentication)
  • DELETE /api/books/{id} : Remove a book from the library. (Requires admin authentication)

Borrowing records:

  • POST /api/borrow/{bookId}/patron/{patronId}: : Borrow a book. (Requires patron authentication)
  • PUT /api/return/{bookId}/patron/{patronId} : Return a borrowed book. (Requires patron authentication)

Authentication

This API uses Basic Authentication. Include the Authorization header in your requests with the format Basic base64(username:password).

Example using curl:

curl -X GET -H "Authorization: Basic base64(username:password)" http://localhost:8080/api/books

License

This project is licensed under the MIT License.

About

Open Source Library Management System API using Spring Boot.

Resources

License

Stars

Watchers

Forks

Languages