Reading list Switch to dark mode

    Magento Architecture

    Updated 9 April 2024

    Magento architecture from different perspectives

    Depending upon your role and purpose for learning more about Magento, there are several different ways to view Magento architecture.

    For example, a developer who wants to create new modules or perhaps customize an existing module will want to understand the architecture of a module itself, and how it fits into the larger view, with the Magento framework and other components.

    However, a merchant who wants to quickly build an online storefront wants to view the collection of components from a higher level, and understand the components that impact the look, feel, and user interaction components.

    Architectural layers overview

    At its highest level, the Adobe Commerce and Magento Open Source framework (Commerce framework) architecture consists of the core product code plus optional modules. These optional modules enhance or replace the basic product code.

    If you are substantially customizing the basic Adobe Commerce or Magento Open Source product, module development will be your central focus. Modules organize code that supports a particular task or feature.

    Searching for an experienced
    Magento 2 Company ?
    Find out More

    A module can include code to change the look and feel of your storefront as well as its fundamental behavior.

    Your modules function with the core product code, which is organized into layers. Understanding layered software patterns is essential for understanding basic Adobe Commerce and Magento Open Source product organization.

    Advantages of layered application design

    • Separation of business logic from presentation logic simplifies the customization process which helps you to alter your storefront appearance without affecting any of the backend business logic.
    • Clear organization of code predictably points extension developers to code location.

    The architecture of Magento 2

    Magento 2 has a Model View ViewModel (MVVM) architecture. This MVVM architecture provides a much more robust separation between the Model and View layer, as it is closely related to the Model View Controller (MVC). A brief description of MVVC is given below:

    Selection_131

    Model

    In the MVC design pattern, the model is the data layer that defines the business logic of the system and also represents the state of the application. The model objects retrieve and store the state of the model in a database.

    Through this layer, we apply rules to data, which eventually represent the concepts our application manages.

    View

    The view is a graphical interface that the users see on the screen. It is responsible for displaying the response to the user request. The view is a structure or a layout, which represents the data in a particular format. Views specify that “how your data looks like”.

    ViewModel

    The ViewModel interacts with the Model layer and exposes only necessary information to the View layer.

    It acts as an interface between the Model and ViewModel to process all the business logic, handle incoming requests, manipulate data using the Model component, and interact with the Views to render the final output.

    Layers in Magento

    Magento 2 is split into four layers, according to the official documentation.

    1. Presentation Layer
    2. Service Layer
    3. Domain Layer
    4. Persistence Layer
    images-1-1

    Presentation Layer

    The presentation layer is the uppermost layer of Magento 2 architecture. When we interact with the web interface of Magento, that time, we are interacting with the presentation layer code. It contains all controllers and View elements such as – layouts, templates, block, css, and js, etc.

    The presentation layer calls the service layer using service contracts, usually. It can overlap business logic.

    Service Layer

    The service layer is the middle layer among the presentation layer and domain layer. It provides a bridge between the presentation and domain layer and resource-specific data. The service layer implements service contracts, which defined using the PHP interface.

    These service contracts allow us to add or change the business logic resource model without breaking the system. This is done using the dependency injection configuration file (di.xml).

    Domain Layer

    The domain layer is responsible for business logic and It does not contain database-specific or resource-specific information. The domain layer defines the generic Magento data objects or models that contain business logic.

    This logic describes which operation can be performed on particular types of data, such as Customer object.

    Persistence Layer

    It describes the resource model, which is responsible for data extraction and modification in the database using the CRUD (Create, Read, Update, and DELETE) requests. For completing these requests, the resource model contains the SQL code.

    Additional business logic capabilities also implemented.

    Know more about Magento architecture.

    Next Blog -> Magento Commands List

    . . .

    Leave a Comment

    Your email address will not be published. Required fields are marked*


    Be the first to comment.

    Back to Top

    Message Sent!

    If you have more details or questions, you can reply to the received confirmation email.

    Back to Home