This project is a backend RESTful API for managing a digital book library.
It is built using Java and Spring Boot.
You can check out the project including Swagger UI —
directly on my website:
https://ofeksagiv.com
To run the project locally (without Docker), make sure you have:
- Java JDK 17 or higher
- Maven
- Git
You can verify the installations using:
java -version
mvn -version
git --versiongit clone https://github.com/OfekSagiv/book-management.git
cd book-managementBefore running the application, you must generate a .env file containing a SECRET_KEY,
which is required for signing JWT tokens in the authentication process.
You can do this in one of the following two ways:
mvn clean compile && mvn exec:java -Dexec.mainClass="com.ofeksag.book_management.utils.EnvFileGenerator"- Open the
EnvFileGeneratorclass located at:
src/main/java/com/ofeksag/book_management/utils/EnvFileGenerator.java - Run the
main()method from your IDE
mvn spring-boot:runThe server will start at:
http://localhost:8080
Once the server is running, you can explore and test the API via Swagger UI at:
http://localhost:8080/swagger-ui/index.html
To access secured endpoints, you must first authenticate using the /auth/login endpoint in Swagger.
Use one of the predefined users:
-
Admin user
username:admin
password:pass -
Regular user
username:user
password:pass
After logging in, you will receive a JWT token.
Note:
You do not need to add the prefixBearermanually.
Just paste the token into the Swagger "Authorize" modal – it will be added automatically.
To make it easier to explore the system, the application starts with:
10preloaded books2predefined users (admin and regular user)
The project includes comprehensive integration tests divided into several categories. Below is an overview of the tests for each category:
To run all tests, execute:
mvn testYou can run the application with Docker in two ways:
Either by building it locally with Docker Compose, or by pulling a prebuilt image.
Requires cloning the project and Docker installed.
git clone https://github.com/OfekSagiv/book-management.git
cd book-management
docker compose build
docker compose up -dNo need to download the project — just pull and run the image.
docker run -d -p 8080:8080 -v h2-data:/app/data ofeksag/book-management-spring:v1.1