Skip to content

an devon4j application

Cristian edited this page Jan 23, 2019 · 15 revisions

An devon4j Application

My Thai Star basics

As an example of how an devon4j application is built we are going to show the My Thai Star application backend project, that can be found in github.

The My Thai Star application is a solution for managing the online booking and orders of a restaurant, it is addressed as a showcase app but designed with real requirements although trying to serve as example of common use cases in web apps (master-detail model, login, authorization based on roles, pagination, search with filters, etc.).

mts

The main features of the app are:

  • anonymous users can book a table.

  • anonymous users can create an event and invite some friends to the restaurant.

  • users can visit the meal catalog and see information about the available dishes (name, ingredients, picture, price).

  • both, the host and the guests, can order food for the event based on the food catalog and can select dishes with extra ingredients.

  • all the booking and order creation / cancellation operations are related to mail notifications sent by the application to warn the involved users about the changes.

  • only users with role waiter are able to access to a restricted area of the application to have access to a list with all of the bookings and orders and can access to the details of each one.

  • the waiters can filter the bookings/orders results to manage the list.

My Thai Star devon4j Backend overview

What we have shown in the previous section is the aspect of a My Thai Star client app that consumes the services created with the devon4j server solution.

From now on we are going to focus on the implementation of that server project to show how is it formed and how you can create your own devon4j server project with the devonfw framework.

My Thai Star project is hosted on github and includes different technologies such as Java, .Net and Node for backend solutions and Angular and Xamarin as default clients.

Note

The My Thai Star project is also included in the devonfw distribution, in workspaces/examples folder.

The devon4j project

Using the devon4j approach for the Java backend project we will have a structure of a main Maven project formed by two sub-projects:

project modules

In the core project we will store all the logic and functionality of the application.

The server project configures the packaging of the application.

The components

In early chapters we have mentioned that the devon4j applications should be divided in different components that will provide the functionality for the different features of the application. Following the naming convention [Target]management being the Target the main entity that we want to manage.

The components, as part of the logic of the app, are located in the core project of the app. In the case of My Thai Star we need to show the different available dishes, we need to manage the booking and the orders and we need to create new users. So the application will be divided in the following components:

project components

The component structure (layers)

Each component of the app is internally divided following the three-layer architecture (service, logic and dataaccess) that Devon4j proposes. So we will have three different packages to order our component’s elements:

component layers

Running MyThaiStar backend

Using Spring Boot features, we can easily run our Java backend applications using the Run as > Java application over the SpringBootApp.java main class

run

Once we see console messages like

Tomcat started on port(s): 8081 (http)
Started SpringBootApp in 15.985 seconds (JVM running for 16.833)

we can start consuming our Java backend.

To show the backend services results we are going to use Postman app for desktop, although you can use any other similar application.

Now, with Postman, we can do a simple GET request to obtain the info of a dish with id=1 (http://localhost:8081/mythaistar/services/rest/dishmanagement/v1/dish/1). And we obtain a result like this

get request

Creating your own devon4j backend app

Once we have seen what we can achieve using devon4j as our backend solution, in next sections we are going to see how to create our own devon4j project step by step, starting from how to create a new devon4j project and explaining how to generate each element of the application.