Summary
A design pattern made for separating concerns.
Here, code is organized into three distinct layers, the model, the view, and the controller (MVC).
I’ve been using this pattern forever when I have been designing REST APIs.
MVC frameworks that I’ve used lol
Model
This is the “data” layer. I like to implement data base models to transport my data. The service layer lives here which calls the repository layer for DB transactions. This layer notifies other layers when data changes.
Service Layer
This layer is always called by the controller or by other services through gRPC and manages business logic. This layer calls the repository layer for DB transactions using ORMs.
Repository Layer
This layer is what manages DB transactions (code-first-approach) and abstracts queries + DB interactions for the service layer. The repository layer interacts with the DB through our DB models.
View
This is the UI basically. This includes request + response (HTTP) schemas for transporting and exposing data as well as our front-end.
Controller
This is the medium between the model and the view. This layer receives user data and orchestrates it.