Online bookshop RESTful web application built in SpringBoot framework for testing RESTful methods for their performances and resource consumption as part of my Master Thesis. This app uses:
- Hibernate ORM for data mapping
- Spring Data JPA for data querying
- Postgres 11 DB
- ProjectLombok for reducing boiler-plate code
- MapStruct for quick bi-directional conversion of DTO and Model classes
- Liquibase for data migration
- Micrometer Metrics for exposing needed metrics via JMX
- First, in order for application to be able to be run, create
sb_app_db_ver2
databasein your DB tool (such as pgAdmin4, DBeaver, DataGrip, etc.) - Make sure that all parameters for database access (database name, db username, password, etc.) located in application.properties file are properly set
- Change location in your terminal to be inside of "SpringBootMasterThesis" project
- Run
mvn clean package
command in terminal (Linux) - Run
mvn spring-boot:run
in terminal (Linux) or via by executingmain
method ofSpringBootMasterThesisApplication.java
class in your IDE.
Here are some API endpoints to target (using Postman or similar tool) including some JSON bodies for HTTP Request:
Get single Author with id=1 http://localhost:8080/api/authors/1
Get all Categories http://localhost:8080/api/categories
Get single Bookhttp://localhost:8080/api/books/1
Create Author http://localhost:8080/api/authors
{
"firstName": "Franz",
"lastName": "Kafka"
}
Create Category http://localhost:8080/api/categories
{
"name" : "Crime",
"isDeleted": false
}
Create Book http://localhost:8080/api/books
{
"title": "The Trial",
"price": 15.50,
"amount": 300,
"isDeleted": false,
"authors": [1],
"categories": [1]
}
Create Order http://localhost:8080/api/orders?username=mica
NOTE: In order this method to work user
table must contain a row with column username
that has a value 'mica'.
JSON Body:
{
"orders": [
{
"bookId": 1,
"amount": 4
}
],
"totalPrice": 62.00
}
Endpoints are same like in GET method section and you need to change same JSON body yourself by following format from POST methods section (JSON bodies are of course for PUT methods)