What is an application architecture?
An application architecture describes the patterns and techniques used to design and build an application. The architecture gives you a roadmap and best practices to follow when building an application so that you end up with a well-structured app.
What is a design pattern?
Design patterns describe repeatable solutions to commonly occurring problems in software design. They are like pre-made blueprints that you can customize to solve a recurring design problem in your code.
Patterns can be linked together to create more generic application architectures. Magento implements a variation of model-view-controller (MVC) architecture as their software architectural pattern.
What is the MVC design pattern?
MVC separates an application into three components—model, view, and controller. Its primary purpose is to segregate data access, user interface, and business logic.
- The model is the system’s modeling layer. Its main purpose is to handle system business rules and data persistence. The model will communicate with the database to get the information.
- The view is responsible for the user information display layer, such as the product page. It is controlled by layout files that assemble blocks, containers, and UI components into a page for display by a web browser. They’re used with PHTML template files to create HTML fragments assembled into the page.
- The controller layer defines clients’ main actions, requests, and responses. Controllers regulate page flows and form submission orchestration.
This pattern is responsible for organizing the system’s process structure at the coding level and providing the means for the system to be scalable and extensible.
What is the architecture of Magento?
In reality, Magento 2 request life cycle is more complex and doesn’t follow the standard MVC approach. Here is what an actual interaction schema looks like:
How does Magento handle requests?
- Magento’s entry point for standard requests is the pub/index.php file. The logic inside this file loads a bootstrap and then creates and runs the application.
- The front controller class iterates through all registered routers in the system to find an appropriate router.
- The router decides where the request will continue, whether it goes to the controller, resolver, or API model.
Learn more about Magento areas here.
How does Magento handle data flow?
The database is only accessed via repositories, factories, and collections, never directly.
You can manipulate entities with repositories, factories, and collections. Entities are represented as models. All of the actual database operations are executed by the resource model. With a resource model, you map the entity properties you created/defined to the database.
Was this article helpful? For more Magento (Adobe Commerce) insights from our certified developers, browse the Magento category in the scandiweb blog. scandiweb is the most certified Magento team in the world—get your dedicated eCommerce growth team. If you need assistance with Magento development, contact our team directly!