# magento/magento2 architecture

> Architecture diagram of the GitHub repository magento/magento2, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-29). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/magento/magento2
- Repository: https://github.com/magento/magento2

## Overview

Magento Open Source is an extensible e-commerce platform. Its principal user journey is browsing a storefront and receiving product or content results; the README establishes the store-building purpose, while the supplied excerpts do not expose the storefront request path or checkout implementation. The graph therefore focuses on evidenced runtime infrastructure and sampled capabilities: URL rewrites, GraphQL cache-tag collection, catalog frontend storage configuration, and CMS/theme media storage. Several connections are omitted because the relevant implementation or wiring was not sampled.

Main entry points: [`app/code/Magento/UrlRewrite/Model/Storage/DbStorage.php`](https://github.com/magento/magento2/blob/2.4-develop/app/code/Magento/UrlRewrite/Model/Storage/DbStorage.php) (URL rewrite storage), [`app/code/Magento/GraphQlCache/Model/CacheableQueryHandler.php`](https://github.com/magento/magento2/blob/2.4-develop/app/code/Magento/GraphQlCache/Model/CacheableQueryHandler.php) (GraphQL cache handler), [`app/code/Magento/Cms/Model/Wysiwyg/Images/Storage.php`](https://github.com/magento/magento2/blob/2.4-develop/app/code/Magento/Cms/Model/Wysiwyg/Images/Storage.php) (CMS image storage), [`app/code/Magento/Theme/Helper/Storage.php`](https://github.com/magento/magento2/blob/2.4-develop/app/code/Magento/Theme/Helper/Storage.php) (Theme media storage)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_runtime["Runtime foundation"]
  node_runtime_entry["Web entry<br/>[index.php]"]
  node_object_factory["Object factory"]
  node_object_manager["Object manager<br/>[ObjectManager.php]"]
  node_directory_list["Directory configuration<br/>[DirectoryList.php]"]
end

subgraph group_storefront["Storefront services"]
  node_storefront_results["Storefront results"]
  node_url_rewrite["URL rewrite storage<br/>[DbStorage.php]"]
  node_catalog_storage["Catalog frontend storage config"]
  node_graphql_cache_handler["GraphQL cache handler"]
  node_cache_identity_pool["Cache identity pool"]
  node_cacheable_query["Cacheable query state"]
end

subgraph group_media["Media management"]
  node_cms_media_storage["CMS image storage<br/>[Storage.php]"]
  node_theme_media_storage["Theme media storage<br/>[Storage.php]"]
  node_media_files[("Media filesystem")]
end

node_shopper(("Store user"))
node_database[("Commerce database")]

node_shopper -.->|"requests store"| node_runtime_entry
node_runtime_entry -.->|"serves results"| node_storefront_results
node_object_factory -->|"creates"| node_object_manager
node_url_rewrite -->|"reads and writes"| node_database
node_url_rewrite -.->|"resolves routes"| node_storefront_results
node_graphql_cache_handler -->|"gets identities"| node_cache_identity_pool
node_graphql_cache_handler -->|"adds cache tags"| node_cacheable_query
node_cms_media_storage -->|"uses directories"| node_directory_list
node_theme_media_storage -->|"uses directories"| node_directory_list
node_cms_media_storage -.->|"manages files"| node_media_files
node_theme_media_storage -.->|"manages files"| node_media_files

click node_runtime_entry "https://github.com/magento/magento2/blob/2.4-develop/pub/index.php"
click node_object_factory "https://github.com/magento/magento2/blob/2.4-develop/lib/internal/Magento/Framework/App/ObjectManagerFactory.php"
click node_object_manager "https://github.com/magento/magento2/blob/2.4-develop/lib/internal/Magento/Framework/App/ObjectManager.php"
click node_directory_list "https://github.com/magento/magento2/blob/2.4-develop/lib/internal/Magento/Framework/Filesystem/DirectoryList.php"
click node_url_rewrite "https://github.com/magento/magento2/blob/2.4-develop/app/code/Magento/UrlRewrite/Model/Storage/DbStorage.php"
click node_catalog_storage "https://github.com/magento/magento2/blob/2.4-develop/app/code/Magento/Catalog/Block/FrontendStorageManager.php"
click node_graphql_cache_handler "https://github.com/magento/magento2/blob/2.4-develop/app/code/Magento/GraphQlCache/Model/CacheableQueryHandler.php"
click node_cms_media_storage "https://github.com/magento/magento2/blob/2.4-develop/app/code/Magento/Cms/Model/Wysiwyg/Images/Storage.php"
click node_theme_media_storage "https://github.com/magento/magento2/blob/2.4-develop/app/code/Magento/Theme/Helper/Storage.php"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_runtime_entry,node_object_factory,node_object_manager,node_directory_list,node_shopper toneBlue
class node_storefront_results,node_url_rewrite,node_catalog_storage,node_graphql_cache_handler,node_cache_identity_pool,node_cacheable_query,node_database toneAmber
class node_cms_media_storage,node_theme_media_storage,node_media_files toneMint
```

## Components

### Runtime foundation

- [Web entry](https://github.com/magento/magento2/blob/2.4-develop/pub/index.php): `pub/index.php`
- [Object factory](https://github.com/magento/magento2/blob/2.4-develop/lib/internal/Magento/Framework/App/ObjectManagerFactory.php): `lib/internal/Magento/Framework/App/ObjectManagerFactory.php`
- [Object manager](https://github.com/magento/magento2/blob/2.4-develop/lib/internal/Magento/Framework/App/ObjectManager.php): `lib/internal/Magento/Framework/App/ObjectManager.php`
- [Directory configuration](https://github.com/magento/magento2/blob/2.4-develop/lib/internal/Magento/Framework/Filesystem/DirectoryList.php): `lib/internal/Magento/Framework/Filesystem/DirectoryList.php`

### Storefront services

- **Storefront results**
- [URL rewrite storage](https://github.com/magento/magento2/blob/2.4-develop/app/code/Magento/UrlRewrite/Model/Storage/DbStorage.php): `app/code/Magento/UrlRewrite/Model/Storage/DbStorage.php`
- [Catalog frontend storage config](https://github.com/magento/magento2/blob/2.4-develop/app/code/Magento/Catalog/Block/FrontendStorageManager.php): `app/code/Magento/Catalog/Block/FrontendStorageManager.php`
- [GraphQL cache handler](https://github.com/magento/magento2/blob/2.4-develop/app/code/Magento/GraphQlCache/Model/CacheableQueryHandler.php): `app/code/Magento/GraphQlCache/Model/CacheableQueryHandler.php`
- **Cache identity pool**
- **Cacheable query state**

### Media management

- [CMS image storage](https://github.com/magento/magento2/blob/2.4-develop/app/code/Magento/Cms/Model/Wysiwyg/Images/Storage.php): `app/code/Magento/Cms/Model/Wysiwyg/Images/Storage.php`
- [Theme media storage](https://github.com/magento/magento2/blob/2.4-develop/app/code/Magento/Theme/Helper/Storage.php): `app/code/Magento/Theme/Helper/Storage.php`
- **Media filesystem**

### Other components

- **Store user**
- **Commerce database**

## Connections

- Store user → Web entry: requests store
- Web entry → Storefront results: serves results
- Object factory → Object manager: creates (evidence: `lib/internal/Magento/Framework/App/ObjectManagerFactory.php`)
- URL rewrite storage → Commerce database: reads and writes (evidence: `app/code/Magento/UrlRewrite/Model/Storage/DbStorage.php`)
- URL rewrite storage → Storefront results: resolves routes
- GraphQL cache handler → Cache identity pool: gets identities (evidence: `app/code/Magento/GraphQlCache/Model/CacheableQueryHandler.php`)
- GraphQL cache handler → Cacheable query state: adds cache tags (evidence: `app/code/Magento/GraphQlCache/Model/CacheableQueryHandler.php`)
- CMS image storage → Directory configuration: uses directories (evidence: `app/code/Magento/Cms/Model/Wysiwyg/Images/Storage.php`)
- Theme media storage → Directory configuration: uses directories (evidence: `app/code/Magento/Theme/Helper/Storage.php`)
- CMS image storage → Media filesystem: manages files
- Theme media storage → Media filesystem: manages files
