https://github.com/shmelovoleksandr/coastersense_backend
My first project on SpringBoot and first time learning about RESTful API
https://github.com/shmelovoleksandr/coastersense_backend
java rest-api spring-boot
Last synced: 2 months ago
JSON representation
My first project on SpringBoot and first time learning about RESTful API
- Host: GitHub
- URL: https://github.com/shmelovoleksandr/coastersense_backend
- Owner: ShmelovOleksandr
- Created: 2025-01-23T16:16:46.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2025-01-23T17:32:46.000Z (over 1 year ago)
- Last Synced: 2025-01-23T21:28:36.653Z (over 1 year ago)
- Topics: java, rest-api, spring-boot
- Language: Java
- Homepage:
- Size: 326 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# CoasterSense (Back-end)
CoasterSense is a college group project made by students of Karel de Grote Hogeschool.
### Team: 19
Team members:
* Artem Diakunchak
* Oleksandr Shmelov
* Mykhailo Kruts
* Leonid Romaniukha
* Yevhen Zinenko
## About
Briefly describing the project, CoasterSense is a smart coaster whos role is to elevate customers' experience in restaurants or cafes. The coaster will automatically notify waiters of customers who needs to be served by measuring the value of drink in the placed glass.
Complete description of the project idea can be found here.
This GitLab repository contains only the back-end part of the final product. To access the rest of the project, you can navigate to:
* Front-end repository
* Arduino repository
## Setup
Application is "ready to run" immediately after copping the repository, as long as you are connected to the KdG local network. This can be done via KdG VPN. Otherwise the application won't be able to access remote database which is located on KdG's servers.
Otherwise, there are a couple of pre-made configuration profiles, in case you want to make some adjustments to the setup of the application. Edit application.properties file to enable them.
* Use "remotedb" profile if you want to use cloud based DB. (Application won't start without KdG network)
* Use "localdb" in order to switch to the locally based H2 database. (Won't have any pre-inserted data)
* Use "jpa_data" for enabling all JPA repositories.
* Use "dummy_data" for enabling "dummy" repositories. (May contain incomplete implementations)
* Use "remote_front" in case you are using remotely based Front-end. (Application won't work with locally base Front-end)
* Use "local_front" in case you are using locally based Front-end. (Application won't work with remotely base Front-end)
## Structure
Application implements three-layered architecture. This setup helps the app run smoothly by dividing its tasks into three main parts. Each of these parts has its own job, making it easier to manage and improve the app over time.
Utilization of REST API allows for future connection of all different types of microservices
## Technologies used
* Spring Boot 3.1.5 (Spring 6) was chosen for the development of the back-end.
* Gradle was used as a build and deployment tool.
* Java 17 was used as a language of development.
* Kotlin was used as a language of Gradle configuration.
* Communication with a cloud-based database is facilitated through the utilization of the Java Persistence API (JPA).
* PostgreSQL was used as a production SQL dialect.
* H2 database as a development assistance tool.
* Application communicates with outside world using REST API.
## Dictionary
* ServingSpace - is a whole business entity. After making an order you will be assigned a unique ID.
* TableGroup - is a group of tables. Examples: "Ground floor", "First floor", "Terrace".
* Table - is an entity which can contain a group of coasters.
* Coaster - is an actual product which measures and sends data.
* Drink - is just a drink with its name, type. Each drink has to have a corresponding empty glass weight and full glass weight.
* Color - each Drink might also have a corresponding Color assigned to it. This is made for drink recognition.
* User - is simply a user of our product. They can login to the website and they can be assigned a role (Admin ot Waiter).
* Delivery - is a delivery order placed by a website visitor.
## API
All data will be returned in JSON format, according to REST conventions.
(Text in curly braces {} indicates a variable in the link)
### Endpoints:
* \[GET\]
* /servingSpaces - returns a list of all ServingSpaces
* /servingSpaces/{ServingSpace_ID} - returns a specific ServingSpace
* /{ServingSpace_ID}/tableGroups - returns a list of all TableGroups for a specific ServingSpace.
* /{ServingSpace_ID}/tableGroups/{TableGroup_ID} - returns a specific TableGroup with given TableGroup_ID for a specific ServingSpace.
* /{servingSpaceId}/tables - returns list of all tables for a specific ServingSpace
* /{ServingSpace_ID}/coasters - returns list of all Coasters for a specific ServingSpace.
* /{ServingSpace_ID}/coasters/free - returns list of all unassigned Coasters for a specific ServingSpace.
* /{ServingSpace_ID}/coasters/{macAddress} - returns the Coaster with given MACAddress.
* /{ServingSpace_ID}/drinks - returns a list of all Drinks for a specific ServingSpace.
* /{ServingSpace_ID}/drinks/history - returns a history of finished Drinks for a specific ServingSpace.
* /{servingSpaceId}/drinks/{colorName} - returns a specific drink for given Color and ServingSpace.
* /colors - returns list of all Colors.
* /colors/{servingSpaceId} - returns list of all Colors used by given ServingSpace.
* /deliveries - returns list of all Deliveries"
* /{servingSpaceId}/stats/days - returns statistics for all days of the week (Index 0 corresponds to Sunday). Statistics includes: average drinking time of all drinks.
* /{servingSpaceId}/stats/drinks - returns "all-time" statistics for all drinks. Statistics includes: average drinking time.
* \[POST\]
* /arduino - updates Coaster's data.
* JSON format:
{
"macAddress": "12:34:56:78:90:ab",
"red": 0,
"green": 0,
"blue": 0,
"weight1": 0,
"weight2": 0,
"weight3": 0,
"weight4": 0,
"timestamp": "2000-01-31T12:00:00Z"
}
* /arduino/configuration - handles received data from arduino configuration.
* JSON format:
Same as in /arduino
* /arduino/message - receives a message and forwards it to the arduino.
* JSON format:
{
"your message"
}
* /contactUs - receives and save a "contact us" form.
* JSON format:
{
"name":"John Doe",
"email":"test@email.com",
"message":"Hello World!"
}
* /colors - save new color to the database.
* JSON format:
{
"name":"BLACK",
"red":0,
"green":0,
"blue":0
}
* /deliveries
* JSON format:
{
"firstName":"John",
"lastName":"Doe",
"email":"test@mail.com",
"city":"Antwerpen",
"postCode":2000,
"street":"Italielei",
"houseNumber":1,
"amountOfCoasters":12
}
* /login - used for a secure login of a user.
* JSON format:
{
"name":"admin",
"password":"admin"
}
* Returns a response with User's role and assigned ServingSpace id.
* Return JSON format:
{
"status": "OK",
"role": "ADMIN",
"servingSpaceId": 1
}
* /servingSpaces - save new entity of ServingSpace into the database.
* JSON format:
{
"name": "Jony's Pizza",
"address": "Street",
"phone": "+32112424",
"email": "pizza@mail.com",
"users": \[
{
"name": "admin",
"password": "admin",
"role": "ADMIN",
"servingSpaceId": 1
}
\]
}
* /{servingSpaceId}/tableGroups - save new entity of TableGroup with assigned ServingSpace into the database.
* JSON format:
\[
{
"name":"table group name",
"coasterQuantities":\[2, 2\],
"tableNames":\["name1", "name2"\]
}
\]
* /{servingSpaceId}/tables/{tableGroupId} - save new entity of Table with assigned TableGroup into the database.
* JSON format:
{
"name": "table name",
"coasters": \[
{
"macAddress": "6f:8d:2a:c4:9e:0b"
}
]
}
* /{servingSpaceId}/coasters - save new entity of Coaster into the database.
* JSON format:
{
"macAddress":"6f:8d:2a:c4:9e:0b",
"drinkColor":"NONE",
"isPlaced":false
}
* /{servingSpaceId}/drinks/{colorName} - save new entity of Drink with assigned ServingSpace and Color into the database.
* JSON format:
{
"name":"cola",
"type":"COFFEE",
"color":{
"name":"RED"
},
"servingSpaceId":1
}
* /{servingSpaceId}/users - save new entity of User with assigned ServingSpace into the database.
* JSON format:
{
"servingSpaceId":1,
"name":"John",
"password":"1234",
"role":"ADMIN"
}
* \[PATCH\]
* /{servingSpaceId}/drinks/{colorName} - updates data for certain Drink.
* JSON format:
{
"name":"cola",
"type":"COFFEE",
"color":{
"name":"RED"
},
"servingSpaceId":1
}
* \[DELETE\]
* /{servingSpaceId}/drinks/{colorName} - deletes certain Drink.