This project is a RESTful API for a simple bookstore management system, built with Java, JAX-RS (Jersey), and Maven. It provides endpoints for managing books, authors, customers, shopping carts, and orders.
- In-Memory Data: Utilizes a non-persistent, in-memory data store. Data will be reset on each application restart.
- CRUD Operations: Full Create, Read, Update, and Delete functionality for Books, Authors, and Customers.
- Shopping Cart: Per-customer cart management.
- Order Placement: Convert a shopping cart into an order, with stock validation.
- Custom Error Handling: Provides meaningful error messages for common issues (e.g., Not Found, Invalid Input).
- Java 21
- JAX-RS (Jersey 2.41): For building RESTful web services.
- Maven: For project build and dependency management.
- Jackson: For JSON serialization/deserialization.
- SLF4J: For application logging.
- Servlet Container: Requires a container like Apache Tomcat or Jetty for deployment.
- Java 21 or later
- Apache Maven
- A servlet container (e.g., Apache Tomcat)
-
Clone the repository:
git clone https://github.com/LoneWolf728/Bookstore_API.git cd Bookstore_API -
Build the project using Maven: This command will compile the source code, run tests, and package the application into a WAR file located in the
target/directory.mvn clean install
-
Deploy the WAR file: Copy the generated
bookstore-1.0-SNAPSHOT.warfile from thetarget/directory to thewebapps/directory of your servlet container (e.g., Apache Tomcat). -
Start the servlet container.
-
Access the API: The API will be available at the base URL:
http://localhost:8080/bookstore-1.0-SNAPSHOT/api
The base path for all endpoints is /api.
POST /authors: Create a new author.GET /authors: Get a list of all authors.GET /authors/{id}: Get a specific author by ID.PUT /authors/{id}: Update an author's details.DELETE /authors/{id}: Delete an author.GET /authors/{id}/books: Get all books by a specific author.
POST /books: Create a new book.GET /books: Get a list of all books.GET /books/{id}: Get a specific book by ID.PUT /books/{id}: Update a book's details.DELETE /books/{id}: Delete a book.
POST /customers: Create a new customer.GET /customers: Get a list of all customers.GET /customers/{id}: Get a specific customer by ID.PUT /customers/{id}: Update a customer's details.DELETE /customers/{id}: Delete a customer.
POST /customers/{customerId}/cart/items: Add an item to the cart.GET /customers/{customerId}/cart: Get the contents of the cart.PUT /customers/{customerId}/cart/items/{bookId}: Update the quantity of an item in the cart.DELETE /customers/{customerId}/cart/items/{bookId}: Remove an item from the cart.
POST /customers/{customerId}/orders: Create a new order from the cart.GET /customers/{customerId}/orders: Get a list of all orders for a customer.GET /customers/{customerId}/orders/{orderId}: Get a specific order by ID.