Search code examples
reactjsspring-bootrestthree-tier

What are the architecture tiers of a Spring Boot + React + MySQL application?


I am trying to write a documentation on the app and I am confused on how to describe the architecture.

From the research I made, I think the presentation tier is my React application, the Business/Application tier is the Spring Boot application and the data Tier is the MySQL.

This looked logic to me, but i stumbled across this tutorial

https://www.youtube.com/watch?v=xJC7ItRoEbw&ab_channel=Amigoscode

where he says at around 10:38 that the controller is part of the Presentation Layer which doesn't seem to link with what I already knew.

And another tutorial https://www.youtube.com/watch?v=udzBtJv2uls&ab_channel=Izenda where it says what I thought initially.

Also I am aware of the fact that the spring boot app has multiple layers control, service and repository (or dao) so I want to combine all this information but I am not 100% sure whether I am going to write some big mistakes or not

Could you please explain me this stuff based on my project? In the frontend, I have the react application that sends fetch requests to typical controllers, which call service methods, which calls repository methods which communicate with the database and execute queries.


Solution

  • In the video the presenter is being very informal and he uses tier and layer interchangeably. Lots of people do that, you have to figure out what is intended by the context.

    To me tier usually implies distribution across different machines. MySQL, the springboot application, and the react code in the client browser are all typically going to be running on different machines, so they are different tiers.

    But the term layers doesn't imply distribution like that, a springboot application can have a webcontroller layer, a service layer, and a data access layer that are all part of the same application artifact. This is a term used to talk about how the logic within the application is organized.

    Spring was originally a response to a prevalent assumption that applications had to be constructed in tiers with web applications that called ejb servers that were hosted on separate clusters and communicated across a network. The spring founders made this distinction between tier and layer to make it easier to explain their approach. This verbiage is used in Rod Johnson's one-to-one book that introduced the main ideas of Spring.

    Whether the controller is part of the presentation layer is debatable. To me presentation means look and feel stuff, controllers do web specific things like exposing endpoints, validating parameters, etc, but especially in a SPA the presentation is in the front end code and the serverside just provides data. Before SPAs controllers would forward to a view that rendered the html on the server, so the controller and presentation were more closely related.