Skip to content

lykon7/Bookstore_API

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Bookstore API

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.

Features

  • 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).

Technology Stack

  • 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.

How to Build and Run

Prerequisites

  • Java 21 or later
  • Apache Maven
  • A servlet container (e.g., Apache Tomcat)

Build

  1. Clone the repository:

    git clone https://github.com/LoneWolf728/Bookstore_API.git
    cd Bookstore_API
  2. 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

Deployment

  1. Deploy the WAR file: Copy the generated bookstore-1.0-SNAPSHOT.war file from the target/ directory to the webapps/ directory of your servlet container (e.g., Apache Tomcat).

  2. Start the servlet container.

  3. Access the API: The API will be available at the base URL: http://localhost:8080/bookstore-1.0-SNAPSHOT/api

API Endpoints

The base path for all endpoints is /api.

Authors

  • 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.

Books

  • 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.

Customers

  • 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.

Shopping Cart

  • 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.

Orders

  • 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.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages