Food is an important part of our daily lives, but most people have no idea what the nutritional values of the foods on their plate are. Additionally, there are some people living with diabetes or some other illness, where it is crucial to know how many carbs you are eating to dose your medication correctly. With this web application we wanted to create a possibility for interested people to learn something about the nutritional values of everyday food in a playful way.
Game logic is in the model component. Its responsibility is to organize the game flow of the whole application.
We have several controller classes. Together they have the responsibility to organize the communication between the front- and backend. They are split according to their parts, that they are organizing. As an example, the class UserController controls the rest communication of the user/* endpoint of our application.
In our project we have three different service classes. They provide functionality to their corresponding entities. As an example, the UserService provides amongst other functionalities the possibility to create, login, logout, update or authenticate a user.
Download your IDE of choice (e.g., IntelliJ, Visual Studio Code, or Eclipse). Make sure Java 17 is installed on your system (for Windows, please make sure your JAVA_HOME
environment variable is set to the correct version of Java).
gradle project
build.gradle
file and choose Run Build
The following extensions can help you get started more easily:
vmware.vscode-spring-boot
vscjava.vscode-spring-initializr
vscjava.vscode-spring-boot-dashboard
vscjava.vscode-java-pack
Note: You'll need to build the project first with Gradle, just click on the build
command in the Gradle Tasks extension. Then check the Spring Boot Dashboard extension if it already shows soprafs23
and hit the play button to start the server. If it doesn't show up, restart VS Code and check again.
You can use the local Gradle Wrapper to build the application.
./gradlew
./gradlew
./gradlew.bat
More Information about Gradle Wrapper and Gradle.
./gradlew build
./gradlew bootRun
You can verify that the server is running by visiting localhost:8080
in your browser.
./gradlew test
You can start the backend in development mode, this will automatically trigger a new build and reload the application once the content of a file has been changed.
Start two terminal windows and run:
./gradlew build --continuous
and in the other one:
./gradlew bootRun
If you want to avoid running all tests with every change, use the following command instead:
./gradlew build --continuous -xtest
We recommend using Postman to test your API Endpoints.
If something is not working and/or you don't know what is going on. We recommend using a debugger and step-through the process step-by-step.
To configure a debugger for SpringBoot's Tomcat servlet (i.e. the process you start with ./gradlew bootRun
command), do the following:
./gradlew bootRun --debug-jvm
Shift + F9
or the use Run/Debug "Name of your task"Have a look here: https://www.baeldung.com/spring-boot-testing
For future additions we have some ideas, what one could implement. The following mentions are not sorted by any means. But are more meant as inspiration for you.
Firstly, there would be the possibility to implement a new game mode. The first additional game mode could be a higher lower implementation of a game. Before starting the game, you would choose your food category, like "Fruits" as well as the nutrition value, you would compare the food items. Let’s assume one would choose "Fruits" and "carbs". Then you would get as first item an apple. A picture of the second item would appear. Let’s assume, it is a pineapple. Now you must decide, if a pineapple has more or less carbs then an apple. If you guessed correctly, you get positive feedback and the next picture of a food item. If you guessed incorrectly, there will be an end of game screen and you can restart.
Another new game mode would be, that you get four pictures of different food Items and additionally the correct nutrition values of one of them. Then you must guess to which food item the displayed nutrition values belong to. If you guessed correctly, you would get new pictures and nutrition values. If not, it is game over.
Another feature for the original game would be a possibility at the end of a game to see all the different questions and answers again, so that one can internalize the different nutrition values of the food items.
This project is licensed under Apache 2.0.