MVC
A user who sees the
view
of the application in thebrowser
and it can make a request with input to arouter
(a request can me alink
that gets clicked). Therouter
will call a specificcontroller method
based on thatroute
, and if data is needed to be fetched thecontroller
will then interact with themodel
, which interacts with thedatabase
. Once thecontroller
gets that data passed back it can then load aview
and it can send the data to theview
and will be dealt with by thetemplate engine
. Once that is all done, it will send theview
back to thebrowser
for the user to see.
Model
Responsible for getting and manipulating the data. The brain of the application. The model usually interacts with some kind of database
MySQL/ MongoDB
Data related logic
Interactions with database
SELECT, INSERT, UPDATE, DELETE
Communicates with Controller
View
Is the user interface with the application (what the users sees).
What the end user sees
UI
Usually consists of
HTML/CSS
Communicates with the controller
Can be passed dynamic values from the controller
Template Engines - allows dynamic data (the use
variables
orlogic
) inside ofviews
Examples -
ERB
(Embedded Ruby),Haml
Controller
Acts as a middleman between the
model
and theview
. The controller will ask themodel
to get some data from the database and the controller will take that data and load aview
and pass that data into it. Then the template engine takes over and do some logic or output for the variables and things like that. The controller can also load aview
without passing it data.
Receives input from
view
,URL
Processes requests
GET
POST
PUT
DELETE
Gets data from the
model
Passes data to the
view
Last updated