:toc: macro toc::[] :idprefix: :idseparator: - ifdef::env-github[] :tip-caption: :bulb: :note-caption: :information_source: :important-caption: :heavy_exclamation_mark: :caution-caption: :fire: :warning-caption: :warning: endif::[] = devon4j Application == MyThaiStar Basics As an example of how a devon4ng application is built, we are going to show the _MyThaiStar_ application front-end project, that can be found in https://github.com/devonfw/my-thai-star[GitHub]. The _MyThaiStar_ application is a solution for managing the online booking and orders of a restaurant. It is presented as a showcase app but designed with real requirements in mind. Moreover, it attempts to demonstrate common features provided by many modern web apps (routing with and without guards, use of flex-box, theme, re-usable components, mock back end, ...). image::images/devon4j/2.Example_app/mts.png[MyThaiStar Home Page] The main features of the app are: * Anonymous users can: ** Book a table. ** Create an event and invite some friends via email. ** See the menu of dishes and make their own orders. * Logged-in users in the role _Waiter_ can also: ** Access a restricted area to see and filter the list and details of all reservations and orders made by users. == MyThaiStar devon4j Back-end Overview In this section we are going to focus on the implementation of the server project. We will show how _MyThaiStar_ is created and how you can kickstart your own _devon4j_ server project with the devonfw framework. The _MyThaiStar_ project is hosted on https://github.com/devonfw/my-thai-star[GitHub] and includes different technologies such as _Java_, _.NET_ and _Node_ for back-end solutions _Angular_ and _Xamarin_ as default clients. === The devon4j Project Using the _devon4j_ approach for the Java back-end project we will have a structure of a main _Maven_ project formed by four sub-projects: image::images/devon4j/2.Example_app/project_modules.png[Maven Project Structure] In the `core` project we will store all the logic and functionality of the application. In the `api` project contains the definitions of all interfaces in the application. The `batch` project contains components related to the https://spring.io/projects/spring-batch[Spring Batch] framework which handles batch processing. 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 _MyThaiStar_ 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: image::images/devon4j/2.Example_app/project_components.png[Application 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: image::images/devon4j/2.Example_app/component_layers.png[Component Layers] == Running MyThaiStar Back-end Using _Spring Boot_ features, we can easily run our _Java_ back-end applications using the _Run as > Java application_ over the `SpringBootApp.java` main class. image::images/devon4j/2.Example_app/run.png[MyThaiStar Back-end Launch] Once we see a console messages like: [source,bash] ---- Tomcat started on port(s): 8081 (http) Started SpringBootApp in XX.XXX seconds (JVM running for XX.XXX) ---- we can start accessing our _Java_ back-end. To show the back-end services results we are going to use https://www.getpostman.com/[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: image::images/devon4j/2.Example_app/get_request.png[Postman Get Request Result] == Creating your own devon4j Back-end App Once we have seen what we can achieve using _devon4j_ as our back-end 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. ''' *Next Chapter*: link:build-devon4j-application[Create your own devon4j App]