MVC (Model-View-Controller) Architecture Explained
h
programmeruser (430)

Here's a quick explanation of of the MVC (Model-View-Controller) architecture.

Model

The model part of a MVC architecture is where your database and application logic goes. This should be independent of the view and controller, so if your model was used in a web app, and reused in a CLI app, it should work perfectly fine.

Controller

The controller is what connects the model and the view. There should be no application logic inside your controller, it should just call the models with user data and serve the views to the user.

View

This is any representation of the data in the application. It could be a web app, a desktop GUI app, or even a CLI app (though web apps are the most common type of view).

Using this with Express.js

  • Your models should go into a models folder
  • Your controllers should go into the routes folder and route with express.Router()
  • And your views should go into the views folder
You are viewing a single comment. View All
Highwayman (1437)

I was excited for the tutorial, but then it ended. I think you could add a bit more to this, maybe make a simple example type thing.