NAE is an end-to-end web application platform based on state-of-the-art open-source and source-available technologies. Two technologies that cover presentation and application layers are Angular and Spring framework. The dynamics of these layers is ensured by the REST API, using HTTP requests to perform CRUD operations in the backend of the application.
Approach with REST API would be enough if communication between frontend and backend was the only allowed one. But usage of NAE backend is not only restricted to its frontend. It is possible to use them separately. For example, you can use backend alone. You can also create brand new frontend that can be based on a different language or framework than Angular. Due to that, we decided to use the extended RESTful API by HATEOAS.
The most significant reason why to use HATEOAS is loose coupling between backend and any frontend. To make a request with REST, you need to know all endpoints definitions upfront. That makes your implementation tightly coupled. With HATEOAS after the first request is fired, a response comes with all possible actions that you can call on the requested resource within the actual application state.
In Picture 1 you can see that the response from the backend contains a name/value pair called “_links”. Embedded tasks response was fired after the user chose a specific case (Order #11). That response contains all possible tasks with all their data and actions. Actions like finish or cancel are all applicable to the task called “Order approval”. Those actions are mentioned in the “_links”. For dynamic web applications as NAE, it is necessary to make hyperlinks for communication available and transparent. It is much easier to know that for tasks there will be action “assign” and that you don’t have to care about specific URLs and IDs for specific actions.
This approach is implemented in every aspect of NAE. After logging into the application you use only links with actions that were sent to you by the system (backend).
NAE as every dynamic and modern web application is using REST API for communication between presentation and application layers. Usage of REST API would be a good solution if the platform was restricted for its actual frontend and backend. But it is not. Long-term designs as HATEOAS are implemented in every aspect of NAE. HATEOAS gives helping hand to developers not only to save their time but also to make them easily understand what to do. Creator of HATEOAS Roy Fielding described this concept: “People are fairly good at short-term design, and usually awful at long-term design”. HATEOAS is not the only possibility, with NAE you can still use classical REST API specified by OpenApi3.