Giter VIP home page Giter VIP logo

bookstore-api's Introduction

๐Ÿ“š Bookstore API ๐Ÿ“š

๐Ÿš€ API Details

  • Created for an online bookstore to enable users to browse and purchase books.
  • Database has two tables: Books and Orders.
  • Books table contains book ID, title, author, price, and quantity information.
  • Orders table stores customer name, order ID, total amount, and date/time of the order.

API Endpoints

  • GET /order - retrieves all orders made in the bookstore
  • POST /order - endpoint allows customers to place an order. The request body should include the customer name, a list of books with their IDs and quantities, and the total amount. This endpoint will create a new order in the Orders table and decrement the quantity of the books in the Books table.
  • PUT /order - allows customers to add or remove books from their cart. The request body should include the customer name, book ID, and quantity. This endpoint will update the quantity of the books in the Books table and return the updated cart with the total amount.
  • DELETE /order/{id} - removes a specific order for a return

โœจ API Response Body โœจ

"statusCode": 200,
"statusDescription": "Orders found",

โœจ API Request Body โœจ

 {
    "orderId": 1,
    "customerName": "George Sucuzhanay",
    "totalAmount": 250,
    "orderDate": "2023-04-20",
    "book": {
        "bookId": 1,
        "title": "Cat in the Hat",
        "author": "Dr. Seuss",
        "price": 25,
        "quantity": 2
    }
},

๐Ÿ‘ฉ๐Ÿฝโ€๐Ÿš€ Goals

  • Online bookstore API provides a convenient and easy way for customers to browse and purchase books
  • API endpoints enable customers to search, add books to cart, and place an order
  • If given more time, implement a decrementor on book quantity everytime a book is purchased

๐Ÿ›ฐ๏ธ SQL Table Creation ๐Ÿ›ฐ๏ธ

CREATE TABLE Books (
    BookId int NOT NULL AUTO_INCREMENT,
    Title varchar(1000) NOT NULL,
    Author varchar(1000) NOT NULL,
    Price int NOT NULL,
    Quantity int NOT NULL,
    PRIMARY KEY (BookId)
)

CREATE TABLE `Orders` (
  `OrderId` int NOT NULL AUTO_INCREMENT,
  `CustomerName` varchar(1000) NOT NULL,
  `TotalAmount` int NOT NULL,
  `OrderDate` date NOT NULL,
  `BookId` int DEFAULT NULL,
  PRIMARY KEY (`OrderId`),
  KEY `FK_BookOrder` (`BookId`),
  CONSTRAINT `FK_BookOrder` FOREIGN KEY (`BookId`) REFERENCES `Books` (`BookId`)
 )

๐Ÿฅณ Thank You! ๐Ÿฅณ

bookstore-api's People

Contributors

george-sucuzhanay avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.