A restful API built on Spring boot that connects to the MySQL database. Application built using Spring Data JPA to perform database operations. Users can add, retrieve, update and delete(CRUD operations) for an online Book store(web app/ website).
-
Java - 17
-
Maven - 3.x.x
-
Mysql - 5.x.x or Ternimal
-
StringBoot - 3.x.x
-
Visual Studio Code(VScode)
1. Clone the application
git clone https://github.com/coderavdhesh/BookCart_restAPI.git
2. Create Mysql database
create database BookCart
3. Change mysql username and password as per your installation
-
open
src/main/resources/application.properties
-
change
spring.datasource.username
andspring.datasource.password
as per your mysql installation
4. Build and run the app using maven (BookCart)
java -jar target/bookcart.jar
Alternatively, you can run the app without packaging it using -
mvn spring-boot:run
The app will start running at http://localhost:7676.
The app defines following CRUD APIs.
GET /books
POST /books/addbook
GET /books/{bookId}
DELETE /books/{bookId}
UPDATE /books/{bookId}
You can test them using postman or any other rest client.
You can find the tutorial/Explanation video for this web application(API) on my youtube account -
RESTFUL API for ONLINE BOOK STORE - BOOKCART
Project Name : BookData_restAPI for the online BookStores Project aim : This API helps to fatch data and also performed CRUD operations to make our website/apps updated with the correct DataSets.
How this API works ?
Web requests and URLs which helps to perform Get/Post/Put/Delete [CRUD operations] --
-
Create [Post] : -> 'localhost:7676/books/addbook', it helps to Create new Books dataset in our database. Note ~ If you will enter wrong URL or RequestBody, Than it will handle the exception and revert the error BAD_REQUEST.
-
Retrieve [Get] : -> 'localhost:7676/books', it helps to retrieve datasets of books from our database. -> 'localhost:7676/books/{id}', it is a Dynamic request, helps to retrieve dataset of a spacific book of the passed Id from our database.
-
Update [Put] : -> 'localhost:7676/books/{id}', it is also a Dynamic request, helps to update the already existing datasets in our database, if the dataset is not available in out database than the code will handle the exception and return the response error of 'NOT_FOUND'.
-
Delete [Delete] : -> 'localhost:7676/books/{id}', it is also a Dynamic request, helps to Delete the already existing datasets in our database, if the dataset is not available in out database than the code will handle the exception and return the response error of 'NO_CONTENT'.
Key Learnings:
Springboot, Spring Data JPA, MySQL Database, SQL, Postman client tool, Java, Spring annotations, Spring MVC(controllers, HTTP URIs), classpath & dependencies, configuration, etc.
- How things are actually working in Backend, Layers in the backend development.
- Familiar with SpringBoot-Architectural Layers and how they are working together to get the data from the database to the end user.
- How we can connect our API with our Database with the help of Spring Data JPA and with full functionality of CRUDs with your APIs.
- Got familiar with the CRUD methods of JPA repo and Database configurations.
- How we can test/check the working of our backend service/APIs using 'POSTMAN TOOL'
- More clarity in core Java concepts.
Used Tools and other Services:
- Postman API tool to get the reponses.
- MySQL server and Interaction with database through terminal.
- VS code to manage this project
- Git(github) to upload this source Code
- No frontend written yet for this API.