MVC Model - bommezijn/Dating-Shreks GitHub Wiki

This topic was worked on by Nathan.

The MVC model is a design pattern to design complex applications and split it into three units. Each has its responsibilities.

The Model: data model, the central part of the pattern, the application's dynamic data structure, it is independent of the user interface. It directly controls the data, the logic, and the rules of the application. E.g., retrieve data from MongoDB, manipulate by filtering by the movie.

  • Handles data logic
  • Interacts with the database (CRUD)

The model never has to think about handling user requests, failure, or success.

The view: The part the user sees on their screen, it is the finish line of the MVC model. The view handles how the data is presented and is dynamically rendered. When rendered without caring how it renders as it is only the visual template that is filled in, it then sends it back to the controller and sends it back to the user (Response).

The Controller: The controller is the part where the user input ends up. E.g., requesting the about us webpage (request). It gets the data from the model. (Request for a page) Ideally, the controller should never directly interact with the data logic but only use the model to do so.

The controller has to think about what to do with the user request, failure, or success from it.

When the controller retrieves the data back from the model, it then has to interact with the view to render the page/ presentation of the application.

If done correctly, the view should never interact with the model and vice versa. If there is any interaction between the two, it is done by the controller.

How it is implemented in Dating Shreks

.
├── Controller
│   └── modules
├── Model
├── View
│   ├── layouts
│   └── partials
└── public
    ├── img
    └── style

Visualisation of MVC model