# bigcommerce/cornerstone architecture

> Architecture diagram of the GitHub repository bigcommerce/cornerstone, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-01-21). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/bigcommerce/cornerstone
- Repository: https://github.com/bigcommerce/cornerstone

## Overview

##### Main Components Structure

Frontend Layer:

- Presentation      |

- Templates           |
- Styles (SCSS)       |
- Client-side JS      |

Core Architecture:

- Theme Structure    |

- Page Types          |
- Components          |
- Layouts             |
- Assets              |

##### Key Relationships to Illustrate

- Page Manager    |     |  Template System  |     |   Asset Pipeline  |

- Global          |     | - Handlebars     |     | - JavaScript     |
- Page-specific   | --> | - Components     | --> | - SCSS           |

##### Component Architecture

- Components    |     |     Utilities    |     |    Integration   |

- Account        |     | - Stencil Utils |     | - BigCommerce   |
- Products       | --> | - Polyfills     | --> | - API           |
- Cart           |     | - Helpers       |     | - Events        |
- Common         |     |                 |     |                 |

##### Important Elements

- Blue: Core theme components
- Green: Integration points
- Orange: Build/compilation processes
- Purple: Runtime features

- Template rendering flow
- Asset compilation pipeline
- Event handling paths
- Data flow between components

- Feature Detection    |

- Browser Check --------->|

- Modern Browser         |
- > Main Bundle     |

- Legacy Browser         |
- > Polyfills       |
- > Main Bundle     |

##### Implementation Details

Build process flow:

- Source Files |     | Build Process  |     | Output Assets  |

- JS (ES6)    |     | - Webpack      |     | - Bundled JS   |
- SCSS        | --> | - Grunt        | --> | - CSS          |
- Templates   |     | - SVG Store    |     | - SVG Sprite   |

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph "Frontend Layer"
        Templates["Templates"]
        Styles["Styles (SCSS)"]
        ClientJS["Client-side JS"]
    end

    subgraph "Core Architecture"
        ThemeStructure["Theme Structure"]
        PageTypes["Page Types"]
        Components["Components"]
        Layouts["Layouts"]
        Assets["Assets"]
    end

    subgraph "Page Management"
        PageManager["Page Manager"]
        Global["Global Context"]
        PageSpecific["Page-specific Context"]
    end

    subgraph "Template System"
        HandlebarsSystem["Handlebars Templates"]
        TemplateComponents["Template Components"]
        TemplateLayouts["Layouts"]
    end

    subgraph "Component Architecture"
        Account["Account"]
        Products["Products"]
        Cart["Cart"]
        Common["Common Components"]
    end

    subgraph "Build Process"
        SourceFiles["Source Files"]
        BuildTools["Build Tools"]
        OutputAssets["Output Assets"]
    end

    subgraph "Integration"
        BigCommerceAPI["BigCommerce API"]
        Events["Events System"]
        Utils["Utilities"]
    end

    %% Relationships
    PageManager --> HandlebarsSystem
    HandlebarsSystem --> Components
    Components --> Assets
    SourceFiles --> BuildTools
    BuildTools --> OutputAssets
    Components --> Utils
    Utils --> BigCommerceAPI

    %% Click Events
    click Templates "https://github.com/bigcommerce/cornerstone/tree/master/templates/"
    click TemplateComponents "https://github.com/bigcommerce/cornerstone/tree/master/templates/components/"
    click TemplateLayouts "https://github.com/bigcommerce/cornerstone/tree/master/templates/layout/"
    click Styles "https://github.com/bigcommerce/cornerstone/tree/master/assets/scss/"
    click ClientJS "https://github.com/bigcommerce/cornerstone/tree/master/assets/js/theme/"
    click PageManager "https://github.com/bigcommerce/cornerstone/blob/master/assets/js/theme/page-manager.js"
    click Account "https://github.com/bigcommerce/cornerstone/blob/master/assets/js/theme/account.js"
    click Products "https://github.com/bigcommerce/cornerstone/tree/master/assets/js/theme/product/"
    click Cart "https://github.com/bigcommerce/cornerstone/tree/master/assets/js/theme/cart/"
    click Common "https://github.com/bigcommerce/cornerstone/tree/master/assets/js/theme/common/"
    click Utils "https://github.com/bigcommerce/cornerstone/tree/master/assets/js/theme/common/utils/"
    click BuildTools "https://github.com/bigcommerce/cornerstone/blob/master/webpack.common.js"
    click Assets "https://github.com/bigcommerce/cornerstone/tree/master/assets/"
    click BigCommerceAPI "https://github.com/bigcommerce/cornerstone/blob/master/assets/js/theme/common/utils/api.js"
    click Layouts "https://github.com/bigcommerce/cornerstone/tree/master/assets/scss/layouts/"

    classDef frontend fill:#e1f5fe,stroke:#01579b
    classDef core fill:#e8f5e9,stroke:#1b5e20
    classDef build fill:#fff3e0,stroke:#e65100
    classDef integration fill:#f3e5f5,stroke:#4a148c

    class Templates,Styles,ClientJS frontend
    class ThemeStructure,PageTypes,Components,Layouts,Assets core
    class SourceFiles,BuildTools,OutputAssets build
    class BigCommerceAPI,Events,Utils integration
```
