Website Architecture: MVC Design Pattern (model, view, Controller)

  • A model is an implementation of an object and its data structure, usually containing database operations.
  • A view represents the user interface, which in web sites is usually the organizational structure of HTML.
  • Controllers are used to process user requests and data flows, complex models, and pass output to the view

Express framework, EJS template engine, MongoDB database to build web site:

  • Route controller in Express, as C
  • Ejs template engine, as V
  • Manipulate the data object model of the database as M

Express

  • Provides a variety of middleware for organizations to build websites
  • Provides routing capabilities that, as a controller, process the requested logic and return the final result to the client

A template engine

After the controller gets the user request, it retrieves the data from the model and invokes the template engine. The template engine takes data and page templates as input, generates HTML pages, and returns them to the controller, which returns them to the client

Mongo database

  • Open source NoSQL database, compared with MySQL relational database, it is more lightweight, flexible, very suitable for the use of large data scale, not strong transactional occasions
  • Called an object database, there are no concepts like tables and rows in traditional SQL
  • All data consists of a large document object, and access to attribute values is flexible