# shopify/horizon architecture

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

- Interactive diagram: https://gitdiagram.com/shopify/horizon
- Repository: https://github.com/shopify/horizon

## Overview

#### Purpose and Runtime
Horizon is Shopify’s first-party Liquid storefront theme. Shopify servers render HTML from Liquid using store data; browser JavaScript progressively enhances the rendered page. The theme runs in evergreen browsers and depends on Shopify’s theme runtime, Storefront data objects, cart APIs, search, localization, and Theme Editor.

#### Entry Points and Page Composition
`layout/theme.liquid` is the primary document shell; `layout/password.liquid` serves password-gated storefronts. Shopify selects JSON/Liquid templates by route, such as `templates/product.json`, `templates/collection.json`, and `templates/cart.json`. Templates assemble configurable sections, whose schemas allow merchant configuration in the Theme Editor.

#### Section and Block Content Model
Sections are the main reusable page stages and own merchant-configurable layouts: `sections/product-information.liquid`, `sections/main-collection.liquid`, and `sections/header.liquid`. They compose theme blocks from `blocks/`, including product, media, text, navigation, and commerce blocks. `sections/_blocks.liquid` and `sections/section.liquid` are key composition/rendering boundaries for this block-oriented architecture.

#### Shared Liquid Presentation Layer
`snippets/` provides shared rendering primitives used across sections and blocks, keeping server-side markup, styles, and Shopify-native formatting centralized. Product UI is concentrated in `snippets/product-card.liquid`, `snippets/product-media-gallery-content.liquid`, and `snippets/variant-main-picker.liquid`; cart drawer markup is centered on `snippets/cart-drawer.liquid`. Theme-wide HTML metadata, CSS, and script inclusion are composed through `snippets/meta-tags.liquid`, `snippets/stylesheets.liquid`, and `snippets/scripts.liquid`.

#### Client Enhancement and Component Boundary
Assets are browser modules/custom-element-style behavior layered onto Liquid markup rather than a client-rendered application. `assets/component.js` supplies a component foundation; `assets/section-hydration.js` connects behavior after server rendering; `assets/section-renderer.js` supports targeted asynchronous section replacement. Core interactive enhancements include dialogs/drawers, media, navigation, and accessibility focus management through `assets/dialog.js`, `assets/theme-drawer.js`, and `assets/focus.js`.

#### Commerce Flows
Product pages render Shopify product/variant state server-side, then synchronize selection, pricing, inventory, and add-to-cart interactions in the browser. The main client path is `assets/variant-picker.js` → `assets/variant-resolution.js` / `assets/product-price.js` → `assets/product-form.js`. Cart interactions use Shopify cart endpoints and update cart UI components, including `assets/cart-drawer.js`, `assets/component-cart-items.js`, and `assets/component-cart-quantity-selector.js`; `sections/cart-drawer-section.liquid` defines the server-rendered drawer target.

#### Discovery, Localization, and Configuration
Collection filtering, sorting, predictive search, and result rendering use Shopify-rendered content with incremental client behavior: `assets/facets.js`, `assets/predictive-search.js`, and `sections/search-results.liquid`. Localization is Shopify-managed and exposed through `assets/localization.js` plus translations in `locales/en.default.json` and peer locale files. `config/settings_schema.json` defines global merchant settings, while `config/settings_data.json` stores their configured values.

Main entry points: [`sections/product-information.liquid`](https://github.com/shopify/horizon/blob/main/sections/product-information.liquid) (Configurable sections), [`layout/theme.liquid`](https://github.com/shopify/horizon/blob/main/layout/theme.liquid) (Document shells), [`assets/component.js`](https://github.com/shopify/horizon/blob/main/assets/component.js) (Component foundation), [`assets/cart-drawer.js`](https://github.com/shopify/horizon/blob/main/assets/cart-drawer.js) (Cart commerce flow)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_shopify["Shopify runtime"]
  node_storefront[("Storefront data &amp; APIs<br/>Shopify platform")]
end

subgraph group_liquid["Liquid composition"]
  node_theme_shell["Document shells<br/>Liquid layouts<br/>[theme.liquid]"]
  node_route_templates["Route templates<br/>JSON templates<br/>[product.json]"]
  node_sections["Configurable sections<br/>Liquid sections"]
  node_section_composition["Section/block renderer<br/>Liquid composition<br/>[_blocks.liquid]"]
  node_blocks["Theme blocks<br/>Liquid blocks"]
  node_shared_snippets["Shared presentation<br/>Liquid snippets<br/>[scripts.liquid]"]
  node_product_ui["Product UI markup<br/>Liquid snippets"]
  node_cart_drawer_markup["Cart drawer target<br/>Liquid section"]
  node_search_markup["Search results<br/>Liquid section"]
end

subgraph group_browser["Browser enhancement"]
  node_component_foundation{{"Component foundation<br/>browser module<br/>[component.js]"}}
  node_section_hydration{{"Section hydration<br/>browser module"}}
  node_interaction_primitives{{"Interaction primitives<br/>browser modules<br/>[dialog.js]"}}
  node_product_commerce["Product commerce flow<br/>browser modules<br/>[variant-picker.js]"]
  node_cart_commerce["Cart commerce flow<br/>browser modules<br/>[cart-drawer.js]"]
  node_discovery["Discovery enhancements<br/>browser modules<br/>[facets.js]"]
end

subgraph group_merchant["Merchant configuration"]
  node_global_settings["Global settings schema<br/>Theme Editor schema"]
  node_settings_values["Configured settings<br/>Theme settings<br/>[settings_data.json]"]
  node_localization["Localization<br/>browser module<br/>[localization.js]"]
  node_translations["Locale translations<br/>locale JSON<br/>[en.default.json]"]
end

node_storefront -->|"renders with Liquid data"| node_theme_shell
node_theme_shell -->|"hosts route content"| node_route_templates
node_theme_shell -->|"includes metadata and assets"| node_shared_snippets
node_route_templates -->|"assembles"| node_sections
node_sections -->|"renders through"| node_section_composition
node_section_composition -->|"composes"| node_blocks
node_sections -->|"uses"| node_shared_snippets
node_blocks -->|"renders product markup"| node_product_ui
node_sections -->|"includes drawer section"| node_cart_drawer_markup
node_shared_snippets -->|"loads browser modules"| node_component_foundation
node_component_foundation -->|"supports"| node_section_hydration
node_section_hydration -.->|"enhances rendered sections"| node_sections
node_component_foundation -->|"provides base behavior"| node_interaction_primitives
node_product_ui -.->|"behavior binds to markup"| node_product_commerce
node_product_commerce -->|"variant and cart requests"| node_storefront
node_cart_drawer_markup -.->|"behavior binds to drawer"| node_cart_commerce
node_cart_commerce -->|"cart endpoint requests"| node_storefront
node_cart_commerce -->|"requests section replacement"| node_section_hydration
node_search_markup -.->|"enhanced by"| node_discovery
node_discovery -->|"search and filtering requests"| node_storefront
node_global_settings -->|"configures"| node_sections
node_settings_values -->|"supplies values for"| node_global_settings
node_translations -->|"provides strings"| node_localization
node_localization -->|"uses Shopify locale state"| node_storefront

click node_theme_shell "https://github.com/shopify/horizon/blob/main/layout/theme.liquid"
click node_route_templates "https://github.com/shopify/horizon/blob/main/templates/product.json"
click node_sections "https://github.com/shopify/horizon/blob/main/sections/product-information.liquid"
click node_section_composition "https://github.com/shopify/horizon/blob/main/sections/_blocks.liquid"
click node_blocks "https://github.com/shopify/horizon/blob/main/blocks/product-card.liquid"
click node_shared_snippets "https://github.com/shopify/horizon/blob/main/snippets/scripts.liquid"
click node_product_ui "https://github.com/shopify/horizon/blob/main/snippets/product-card.liquid"
click node_cart_drawer_markup "https://github.com/shopify/horizon/blob/main/sections/cart-drawer-section.liquid"
click node_component_foundation "https://github.com/shopify/horizon/blob/main/assets/component.js"
click node_section_hydration "https://github.com/shopify/horizon/blob/main/assets/section-hydration.js"
click node_interaction_primitives "https://github.com/shopify/horizon/blob/main/assets/dialog.js"
click node_product_commerce "https://github.com/shopify/horizon/blob/main/assets/variant-picker.js"
click node_cart_commerce "https://github.com/shopify/horizon/blob/main/assets/cart-drawer.js"
click node_discovery "https://github.com/shopify/horizon/blob/main/assets/facets.js"
click node_search_markup "https://github.com/shopify/horizon/blob/main/sections/search-results.liquid"
click node_global_settings "https://github.com/shopify/horizon/blob/main/config/settings_schema.json"
click node_settings_values "https://github.com/shopify/horizon/blob/main/config/settings_data.json"
click node_localization "https://github.com/shopify/horizon/blob/main/assets/localization.js"
click node_translations "https://github.com/shopify/horizon/blob/main/locales/en.default.json"

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_storefront toneBlue
class node_theme_shell,node_route_templates,node_sections,node_section_composition,node_blocks,node_shared_snippets,node_product_ui,node_cart_drawer_markup,node_search_markup toneAmber
class node_component_foundation,node_section_hydration,node_interaction_primitives,node_product_commerce,node_cart_commerce,node_discovery toneMint
class node_global_settings,node_settings_values,node_localization,node_translations toneRose
```

## Components

### Shopify runtime

Server rendering, store data, and platform APIs.

- **Storefront data & APIs**: Shopify platform · Provides Liquid objects, cart, search, and localization services.

### Liquid composition

Route templates, configurable sections, blocks, and shared markup.

- [Document shells](https://github.com/shopify/horizon/blob/main/layout/theme.liquid): Liquid layouts · Primary and password-gated HTML shells. · `layout/theme.liquid`
- [Route templates](https://github.com/shopify/horizon/blob/main/templates/product.json): JSON templates · Shopify selects templates for product, collection, and cart routes. · `templates/product.json`
- [Configurable sections](https://github.com/shopify/horizon/blob/main/sections/product-information.liquid): Liquid sections · Merchant-configurable page stages and layouts. · `sections/product-information.liquid`
- [Section/block renderer](https://github.com/shopify/horizon/blob/main/sections/_blocks.liquid): Liquid composition · Central boundary for rendering block-oriented sections. · `sections/_blocks.liquid`
- [Theme blocks](https://github.com/shopify/horizon/blob/main/blocks/product-card.liquid): Liquid blocks · Reusable product, media, text, navigation, and commerce content. · `blocks/product-card.liquid`
- [Shared presentation](https://github.com/shopify/horizon/blob/main/snippets/scripts.liquid): Liquid snippets · Centralizes shared markup, metadata, styles, scripts, and Shopify formatting. · `snippets/scripts.liquid`
- [Product UI markup](https://github.com/shopify/horizon/blob/main/snippets/product-card.liquid): Liquid snippets · Cards, media gallery, and variant picker markup. · `snippets/product-card.liquid`
- [Cart drawer target](https://github.com/shopify/horizon/blob/main/sections/cart-drawer-section.liquid): Liquid section · Server-rendered target for drawer updates. · `sections/cart-drawer-section.liquid`
- [Search results](https://github.com/shopify/horizon/blob/main/sections/search-results.liquid): Liquid section · Server-rendered search result content. · `sections/search-results.liquid`

### Browser enhancement

Progressive JavaScript behaviors over rendered markup.

- [Component foundation](https://github.com/shopify/horizon/blob/main/assets/component.js): browser module · Custom-element-style component behavior. · `assets/component.js`
- [Section hydration](https://github.com/shopify/horizon/blob/main/assets/section-hydration.js): browser module · Attaches behavior and supports targeted section replacement. · `assets/section-hydration.js`
- [Interaction primitives](https://github.com/shopify/horizon/blob/main/assets/dialog.js): browser modules · Dialog, drawer, and focus-management behavior. · `assets/dialog.js`
- [Product commerce flow](https://github.com/shopify/horizon/blob/main/assets/variant-picker.js): browser modules · Resolves variants and synchronizes price, inventory, and add-to-cart. · `assets/variant-picker.js`
- [Cart commerce flow](https://github.com/shopify/horizon/blob/main/assets/cart-drawer.js): browser modules · Updates cart items, quantities, and drawer UI through cart endpoints. · `assets/cart-drawer.js`
- [Discovery enhancements](https://github.com/shopify/horizon/blob/main/assets/facets.js): browser modules · Facets and predictive search enhance Shopify-rendered results. · `assets/facets.js`

### Merchant configuration

Theme Editor settings and localization.

- [Global settings schema](https://github.com/shopify/horizon/blob/main/config/settings_schema.json): Theme Editor schema · Defines merchant-configurable theme settings. · `config/settings_schema.json`
- [Configured settings](https://github.com/shopify/horizon/blob/main/config/settings_data.json): Theme settings · Stores merchant-selected setting values. · `config/settings_data.json`
- [Localization](https://github.com/shopify/horizon/blob/main/assets/localization.js): browser module · Exposes Shopify-managed locale behavior and translations. · `assets/localization.js`
- [Locale translations](https://github.com/shopify/horizon/blob/main/locales/en.default.json): locale JSON · `locales/en.default.json`

## Connections

- Storefront data & APIs → Document shells: renders with Liquid data
- Document shells → Route templates: hosts route content
- Document shells → Shared presentation: includes metadata and assets
- Route templates → Configurable sections: assembles
- Configurable sections → Section/block renderer: renders through
- Section/block renderer → Theme blocks: composes
- Configurable sections → Shared presentation: uses
- Theme blocks → Product UI markup: renders product markup
- Configurable sections → Cart drawer target: includes drawer section
- Shared presentation → Component foundation: loads browser modules
- Component foundation → Section hydration: supports
- Section hydration → Configurable sections: enhances rendered sections
- Component foundation → Interaction primitives: provides base behavior
- Product UI markup → Product commerce flow: behavior binds to markup
- Product commerce flow → Storefront data & APIs: variant and cart requests
- Cart drawer target → Cart commerce flow: behavior binds to drawer
- Cart commerce flow → Storefront data & APIs: cart endpoint requests
- Cart commerce flow → Section hydration: requests section replacement
- Search results → Discovery enhancements: enhanced by
- Discovery enhancements → Storefront data & APIs: search and filtering requests
- Global settings schema → Configurable sections: configures
- Configured settings → Global settings schema: supplies values for
- Locale translations → Localization: provides strings
- Localization → Storefront data & APIs: uses Shopify locale state
