This project is a Library Management System that provides functionalities for managing books, patrons, and borrowing records. It includes RESTful APIs for user authentication, book management, patron management, and borrowing record management.
- User Authentication: Users can register and authenticate to access the system.
- Book Management: CRUD operations for managing books, including addition, update, retrieval, and deletion.
- Patron Management: CRUD operations for managing patrons, including addition, update, retrieval, and deletion.
- Borrowing Record Management: Functions for recording book borrowing and return.
To run the project locally, follow these steps:
- Clone the repository to your local machine:
git clone https://github.com/AbdelrhmanSror/Library-Management-System.git
- Navigate to the project directory:
cd Library-Management-System
- Build the project using Maven:
mvn clean package
- Run the application:
java -jar target/Library-Management-System.jar
The application will start on port 5000
by default.
The project includes unit tests for ensuring the correctness and integrity of the implemented functionalities. You can run the tests using the following Maven command:
mvn test
The project utilizes Swagger for API documentation. Once the application is running, you can access the Swagger UI by navigating to the following URL in your web browser:
http://localhost:5000/swagger-ui/index.html#/
From the Swagger UI, you can explore and interact with the available endpoints, view request and response schemas, and test the APIs directly.
-
User Registration: To access the endpoints, you need to register with a username and password. Use the following endpoint to register:
- Endpoint:
POST /api/v1/authentication/register
- Example Request Body:
{ "username": "your_username", "password": "your_password" }
- Example Response:
{ "result": "successfully added" }
- Endpoint:
-
Authentication: After registration, authenticate to obtain a JWT token for accessing other endpoints. Use the following endpoint:
- Endpoint:
POST /api/v1/authentication
- Example Request Body:
{ "username": "your_username", "password": "your_password" }
- Example Response:
{ "token": "eyJhbGciOiJIUzUxMiJ9.eyJuYW1lIjoiMSIsImlkIjoxLCJzdWIiOiIxIiwiaWF0IjoxNzE1NTQ3MjA2LCJleHAiOjE3MTU1NTQ0MDZ9.g7QgZct0ttSxqd-iJlZbjZK4VOAFKTwjiManM6gk-LatsUxj8zUrghetwEGiLxLv-f3ITuzuoBY6SWMTfsq6cA" }
- Endpoint:
-
Authorization: Copy the JWT token received and click on the "Authorize" button at the top-right corner of the Swagger UI. Paste the token in the "Value" field, then click "Authorize" to enable access to secured endpoints.
-
Using Endpoints: Once authorized, you can use the endpoints as needed. Please note that to create a borrowing record, you must first add books and patrons and obtain their IDs, which you'll provide to the borrowing endpoint.