DEV Community

Discussion on: How do you implement REST in an MVC application?

Collapse
 
drmandible profile image
DrMandible • Edited

MVC is a modeling technique used in server (aka back end) software.

So, to be clear, MVC is not something you would implement in react. (edit: Technically you could, but that's not something that would involve a rest api. So not relevant here.)

Your react app would make https calls (often via axios or fetch api) to your server. That server interprets those requests using the MVC you've implemented.

For a more in depth explanation, you should research Node js and its indispensable library, Express. I've learned a lot about those from Academind on YouTube.

Collapse
 
evgeniir profile image
Evgeniy • Edited

"MVC is a modeling technique used in server (aka back end) software."

A popular point of view, but it's not entirely true, MVC was invented by Trygve as an architecture for desktop applications. (source - folk.uio.no/trygver/2007/MVC_Origi... )

What's now commonly called MVC actually is MVA

To be honest, trying to follow MVC(or MVA) is not something you really need to think about when designing an application.

@jouo
When designing programs, it is important what the components are responsible for, and what they do. Not the technical details of implementation, such as HTTP communication.

If we consider "model" as a domain model, there should not be any external dependencies, except Entity/Value objects that are part of it(like ProductProfile class can be part of Product).

If it's frontend for web application, just don't care about MVC.