#####Mendix Assignment #Simple Cooking App ######Ionut-Laurentiu Holbea
##Overall application architecture The application has multiple parts:
BACKEND- developed usingJavaandSpring BootFRONTEND- developed usingMendix Desktop ModelerPERSISTANCY- the database that I've used is aPostgreSQLdatabase hosted on cloud usingAWS RDS. I first started the development with aH2in-memory database, but I wanted to add a bit more functionality to the app, so I switched to a cloud DB.
###Folder Structure
The BACKEND of the application resides in the cookingAppBackend folder.
It contains the src folder with the application and three .bat files that are explained in the How to Run section.
The FRONTEND of the application resides in the cookingAppFrontend folder. Given the fact that I didn't find the
Export Package functionality of the Modeler until later in the development, I've added the entire working directory
of the FRONTEND.
Besides these two folders in the root folder there is another one, Generated Objects. It contains, a .jar with the
backend functionality, an application.properties used by Spring Boot to run the application, a .mpk file (the interface
developed in Mendix) and a .bat file. These are used to run the application. More info in the How to Run section.
##Prerequisites In order to run the application you need the following tools:
- Latest JDK installed
- JAVA_HOME Environment Variable set
- Mendix Modeler
##How to Run
In the Generated Objects folder I've provided all the necessary objects in order to start the application.
Starting the BACKEND is easy, simply execute the run.bat script file. This calls java -jar %JARNAME% and uses the
application.properties to connect to the database.
In order to start the FRONTEND you have to import the .mpk in the Mendix Modeler and simply Run Locally. After
the building is complete you can click the View(at the top of the application) to open the FRONTEND.
##How to Build
If you want to build the BACKEND .jar yourself, all you have to do is to go to cookingAppBackend folder.
Here you will find the 3 .bat files that I've mentioned earlier. Let's take them one by one:
run.bat- it's similar to therun.batfrom theGenerated Objectsfolder, but with different paths.test.bat- using themvnw(Maven wrapper) it runs themvn testcommand, to start testing the applicationsinstall.bat- using themvnw(Maven wrapper) it runs themvn clean installcommand, that clears thetargetfolder, runs the tests and the builds the.jar. The generated.jaris gonna be in thetargetfolder.
##How to Use
After everything was executed correctly and the application started, both FRONTEND and BACKEND, a login screen will
appear. The username is MxAdmin and the password is 1. Using Mendix Security Demo/Prototype functionality I've added
two types of users Chef and User to help see the functionality of the pages.
Let's take the application page by page and explain what functionality each type of user has access to:
Homepage
- it's a dashboard with all the recipes in the database. It contains a list of cards for each recipe.
Each cards consists of title, description, a section for ingredients, a section with the steps and the categories for
that recipe.
- For the
Chef, three buttons will be available here :View Recipe,Edit Recipe,Delete. - For the
User, only theView Recipebutton will be available. This will redirect us to theRecipe Detailspage.
- For the
- at the top of the
Homepagethere are two buttons,Create RecipeandSearch- For the
Chef, both buttons will be available - For the
User, only theSearchbutton will be available
- For the
- default number of shown elements is five, to load more, click on the
Load Morebutton at the bottom of the page.
Create Recipe
- it's a page that helps the
Chefto add new recipes. It contains fields for every entity of the recipe. - this page is only available to the
Chef
Recipe Details
- on this page you can get either using the
View Recipeor theEdit Recipebutton. The difference is that, when coming from theView Recipebutton, the data is not editable. It's used for theUser, but theChefalso has access to it, to see how does the newly created recipe look to theUser.
Search Recipe
- hitting the
Searchbutton or navigating from the top of the page to the 'Search' takes us to theSearch Recipe. - it contains as input for category, a
Searchbutton and aCancelbutton, that redirects us to theHomepage. - when clicking
Searchan API call that returns a list of recipes filtered by category is returned and we're redirected to theResults Page. - if the list is empty a warning message will appear.
Results Page
- is similar to the
Homepagebut with the recipes list filtered by the selected category.
#####Functionalities by user type:
Chef:
- Create recipe
- Delete recipe
- Edit recipe
- View recipe
- Search recipe by category
- View recipe list
User:
- View recipe
- Search recipe by category
- View recipe list
##Implementation
######BACKEND
The BACKEND, as said above, is developed using Java and Spring Boot.
It consists of Controllers, Services, Entities, Exceptions, Repositories and Tests.
The mapping for each http request is done in the controllers, then the information is sent to the service implementation.
In the service implementation I @Autowire the repository that extends JpaRepository. In the repository I've created some
custom querys to retrieve the data in the way that I needed it.
When a recipe was not found I threw a RecipeNotFoundException with a specific message.
In the test folder of the BACKEND you can find the tests for Controllers, Services and Repositories. You can run them
either using the mvn test, provided you have the Maven installed, or using the test.bat script that I've provided.
The steps, ingredients and categories are stored not as list of strings, but as simple strings. Why I've decided to use them like these?
Because let's assume that the CHEF want to create a recipe really fast, copying some information from the internet. With the list, he would
have to click an Add Ingredient/Step for each new line of the recipe. With the elements stores as strings, he can simply copy-paste the recipe
and format it as he wants.
######FRONTEND
The FRONTEND was developed using the Mendix Desktop Modeler. I've created the needed pages.
In order to get that from the BACKEND API I've created microflows as needed.
The users are created using the Security module with Demo/Prototype option. That way you can login with a master password
and switch between the users to see how each page changes.
PS: A visible API Documentation can be found at: https://documenter.getpostman.com/view/5293766/RWgp2KgW#ddc12663-cc71-4223-b7aa-c0721127a8f0
I've generated it using POSTMAN.