EasyLib is a personal library management API, designed to help users organize their personal book collections and manage their library with ease.
-
User Management
- CRUD operations for users.
-
Book Management
- CRUD operations for books.
-
Library Management
- Create a library for a user.
- Add and remove books from the library.
- Delete or clear libraries.
Entity Relationships:
- A User has a one-to-one relationship with a Library.
- A Library has a many-to-many relationship with Books.
- Java 21
- Maven 3.x
- Spring Boot 3.x
- PostgreSQL (or another database supported by Spring Data JPA)
Note: If you are using a different database, make sure to include the appropriate database driver dependency in your pom.xml
.
-
Clone the repository:
git clone https://github.com/tuchanski/easylib
-
Navigate to the project directory:
cd easylib
-
Run SQL script to create database:
psql -U [username] -f db_script/easylib.sql
Note: If you are using a different database than PostgreSQL, this command will vary.
-
Build the project:
mvn clean install
-
Run the application:
mvn spring-boot:run
-
Access the API documentation:
- Open your browser and go to
http://localhost:8080/swagger-ui.html
to view the OpenAPI documentation.
- Open your browser and go to
- Spring Boot Starter Data JPA
- Spring Boot Starter Web
- Spring Boot Starter Validation
- PostgreSQL Driver
- SpringDoc OpenAPI
- Lombok
Here are some of the main endpoints:
-
User Endpoints:
POST api/users
: Create a new user.GET api/users
: Retrieve all users.GET api/users/{userId}
: Retrieve a user by ID.PUT api/users/{userId}
: Update a user by ID.DELETE api/users/{userId}
: Delete a user by ID.
-
Book Endpoints:
POST api/books
: Create a new book.GET api/books
: Retrieve all books.GET api/books/{bookId}
: Retrieve a book by ID.PUT api/books/{bookId}
: Update a book by ID.DELETE api/books/{bookId}
: Delete a book by ID.
-
Library Endpoints:
POST api/libraries/{userId}
: Create a library for a user.POST api/libraries/{libraryId}/add-book/{bookId}
: Add a book to a library.GET api/libraries
: Retrieve all libraries.GET api/libraries/{libraryId}
: Retrieve a library by ID.DELETE api/libraries/{libraryId}/del-book/{bookId}
: Remove a book from a library.DELETE api/libraries/{libraryId}
: Delete a library by ID.DELETE api/libraries/{libraryId}/clear
: Clear all books from a library.
This project is licensed under the MIT License - see the LICENSE file for details.