Skip to content

Simple Bookstore management project with Spring Boot Rest API

Notifications You must be signed in to change notification settings

mrgoyell/Bookstore

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

30 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

BookStore

A basic bookstore management system.

Developement

Languages & Frameworks

The application has been developed in java using Spring Boot framework for creating Rest APIs. By default the application has been exposed to Port 8080. This can be modified from the application.properties

Database

To connect the database with spring boot JDBC connector is used and repositories are extended from Spring Data JPA. The application supports the use of 2 separate databases via switching profile:

  • H2 (current-default) : This is an in memory database and any new data stored will be cleared at the end of execution. Database can be set be setting the active-profile to test. Its properties can be modified from application-test.properties. Default entries in the database have been added in Data.sql it can be modified.(Note: Modifying this file might affect some repository unit tests created)

  • MYSQL: This can connect to the local database created on MYSQL. By default it expects a database by the name of Bookstore on Port 3306. This can be changed from application-mysql.properties

Entities

Book

  • Isbn ~ String ~ ID
  • Title ~ String ~ Not Empty
  • Author ~ String ~ Not Empty
  • Price ~ Float ~ Not Null
  • Quantity ~ Integer ~ Default:1

API Services

  • Add Book

    Adds Book to the bookstore

    • Endpoint: POST /books

    • Request Body (sample):

      { "isbn": "fef", "title": "reprehenderit", "author": "ddd ", "price": 22.3, "quantity": 2 **(Optional)** }
    • Success Response:

      • Code: 201 CREATED
        Content(sample):

        { "isbn": "fef", "title": "reprehenderit", "author": "ddd ", "price": 22.3, "quantity": 2 }
    • Error Response:

      • Code: 400 BAD REQUEST
        Content(sample):

        { "timestamp": "2020-06-22T08:15:16.934+00:00", "status": 400, "error": "Bad Request", "message": "", "path": "/books/" }

  • Search Book

    Search a book in the bookstore by isbn,title(partial matching),author(partial matching)

    • Endpoint: GET /books

    • Params: &search

    • Success Response:

      • Code: 200
        Content(sample):

        {
          "_embedded": {
            "books": [
              {
                "title": "refe",
                "author": "dew",
                "price": 2.45,
                "quantity": 4,
                "_links": {
                  "self": {
                    "href": "http://localhost:8080/books/ywef"
                  },
                  "book": {
                    "href": "http://localhost:8080/books/ywef"
                  }
                }
              }
            ]
          },
          "_links": {
            "self": {
              "href": "http://localhost:8080/books/search/byParams?search=ew"
            }
          }
        }
        
    • Error Response:

      • Code: 204 NO CONTENT
  • Get Media Coverage

    Searches a book by isbn & finds its media coverage from TypiCode and returns all the titles of the media coverages found

    • Endpoint: GET /books/{isbn}/getMediaCoverage

    • Success Response:

      • Code: 200
        Content(sample):

        [
            "sunt aut facere repellat provident occaecati excepturi optio reprehenderit",
            "qui est esse",
            "dolorem eum magni eos aperiam quia",
            "eveniet quod temporibus"
        ]
        
    • Error Response:

      • Code: 404 NOT FOUND
        (Invalid ISBN)

      OR

      • Code: 204 NO CONTENT
        (TypiCode API not available or no media coverage found for the book)
  • Buy Book

    Buys a copy of the book (if exists) from the bookstore. It will add another copy to the bookstore if last copy of the book was sold.

    • Endpoint: GET /books/{isbn}/buy

    • Success Response:

      • Code: 202 ACCEPTED
        Content: "Purchased Successfully"
    • Error Response:

      • Code: 404 NOT FOUND
        (Invalid ISBN)

      OR

      • Code: 204 NO CONTENT
        (Sold Out)

Deployment

The application can be run as a docker container. Maintained docker repository can be found at mrgoyell/bookstore Currently the following tags are supported:

  • latest: Will pull the latest image on the master branch.

Execution

After installing docker on your system/server. The image can be pulled by:

docker pull mrgoyell/bookstore:

After successfully pulling the image you can run the application by:

sudo docker run -p 8080:8080 -d -t mrgoyell/bookstore:

About

Simple Bookstore management project with Spring Boot Rest API

Resources

Stars

Watchers

Forks

Releases

No releases published