this section is talking about Model, View, Controller architecture
MVC ( Model View Controller ) is a kind of software architecture.
It splits the UI and business logic into three parts:
- Model
- View
- Controller
There are many versions of MVC definition. And we are talking about the Model2 here.
Model2 is a specific design for web application.
Requests are passed to the controller.
The controller performs any logic necessary to obtain the correct content from model.
The model contains business logic to process data.
The controller pass processed data to view to render the response.
- Ruby on Rails
- Laravel
- Django
The model contains all business logic
- Database Operations
- Action Policies
The view renders the data
- Render HTML
- Render JSON
The controller processes requests and passes data from specific model to specific view
A client wants to get the specific user data :
-
controller checks its request format
-
controller calls model to get specific user data
-
model connects to the database then reads data
-
controller passes the data to view
-
view render the user data in JSON
-
response is passed to the client