# vtex-apps/store-components architecture

> Architecture diagram of the GitHub repository vtex-apps/store-components, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-05-14). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/vtex-apps/store-components
- Repository: https://github.com/vtex-apps/store-components

## Overview

##### Project type and purpose
- This is an **open-source component library** (VTEX Store Components) that supplies reusable React blocks to be consumed by VTEX Store Theme apps.
- It uses VTEX’s **store** and **styles** builders, exposes a manifest.json, GraphQL queries/mutations, i18n message bundles, docs, tests, and mocks.

##### File structure
- Top level:
- Configuration and tooling (.eslintrc, .prettierrc, .github workflows, husky hooks)
- docs/ – Markdown docs per UI block
- messages/ – JSON bundles for internationalization
- manifest.json – VTEX IO app definition (builders & dependencies)
- react/ – source code of the component library:
– components (each block under react/components/…)
– GraphQL schemas (react/graphql/*.gql)
– typings, utils, tests, mocks, package.json, tsconfig
- store/ – JSON schemas for VTEX store builder
- Patterns:
- Modular React components organized per block
- Usage of GraphQL for data fetching (queries & mutations)
- CSS Handles pattern for style overrides
- Mocks and tests emphasize isolation for CI

##### Key insights from README
- Uses the **store** builder (block architecture) and **styles** builder
- Consumers import “vtex.store-components” in their store theme’s manifest
- Each component is a “block” in the VTEX Store framework
- Extensibility via CSS API and custom style files
- CI via Travis/GitHub Actions, tests via Jest

##### Detail
- Every folder/module that contributes to the public API or build
- Both development-time (lint, test, build) and runtime flows
- Don’t shy away from breaking out sub-modules if they represent distinct responsibilities (e.g., GraphQL vs. Styling vs. i18n)

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Consumer
    subgraph "Consumer: VTEX Store Theme App"
        Consumer["Store Theme App"]:::app
    end

    %% Component Library
    subgraph "VTEX Store Components Library"
        direction TB
        Manifest["manifest.json"]:::config
        ReactComp["React Components"]:::code
        GraphQLMod["GraphQL Schemas (.gql)"]:::code
        Styles["CSS Handles & Styles"]:::code
        I18n["i18n Messages"]:::code
        Utils["Utility Modules"]:::code
        Typings["TypeScript Typings"]:::code
    end

    %% Build & CI
    subgraph "Build & CI Pipeline"
        direction TB
        Builders["VTEX IO Builders (store, styles)"]:::build
        LintFmt["ESLint & Prettier"]:::build
        Hooks["Husky Git Hooks"]:::build
        CI["GitHub Actions / Travis CI"]:::build
    end

    %% Testing Environment
    subgraph "Testing Environment"
        direction TB
        Tests["Jest & React Testing Library"]:::test
        Mocks["Component Mocks"]:::test
    end

    %% Runtime Services
    subgraph "VTEX Platform Services"
        direction TB
        GQLGateway["GraphQL Gateway"]:::runtime
        DataServices["Catalog, Checkout, Shipping"]:::runtime
        CDN["CDN for Static Assets"]:::runtime
    end

    %% Interactions
    Consumer -->|imports blocks| ReactComp
    Consumer -->|imports manifest| Manifest
    ReactComp -->|uses queries| GraphQLMod
    ReactComp -->|requests data| GQLGateway
    GraphQLMod -->|hands off| DataServices
    Styles -->|style override| Consumer
    I18n -->|loads messages| Consumer
    Builders -->|build assets| Consumer
    LintFmt -->|lint & format| ReactComp
    Hooks -->|pre-commit checks| LintFmt
    CI -->|runs tests| Tests
    Tests -->|uses mocks| Mocks
    Mocks -->|simulate data| ReactComp

    %% Click Events
    click Manifest "https://github.com/vtex-apps/store-components/blob/master/manifest.json"
    click ReactComp "https://github.com/vtex-apps/store-components/tree/master/react/components/"
    click GraphQLMod "https://github.com/vtex-apps/store-components/tree/master/react/graphql/"
    click I18n "https://github.com/vtex-apps/store-components/tree/master/messages/"
    click Utils "https://github.com/vtex-apps/store-components/tree/master/react/utils/"
    click Typings "https://github.com/vtex-apps/store-components/tree/master/react/typings/"
    click Tests "https://github.com/vtex-apps/store-components/tree/master/react/__tests__/"
    click Mocks "https://github.com/vtex-apps/store-components/tree/master/react/__mocks__/"
    click Builders "https://github.com/vtex-apps/store-components/blob/master/store/contentSchemas.json"
    click Builders "https://github.com/vtex-apps/store-components/blob/master/store/interfaces.json"
    click Hooks "https://github.com/vtex-apps/store-components/tree/master/.husky/pre-commit"
    click LintFmt "https://github.com/vtex-apps/store-components/blob/master/.eslintrc"
    click LintFmt "https://github.com/vtex-apps/store-components/blob/master/.prettierrc"
    click LintFmt "https://github.com/vtex-apps/store-components/blob/master/.eslintignore"
    click LintFmt "https://github.com/vtex-apps/store-components/blob/master/.prettierignore"
    click CI "https://github.com/vtex-apps/store-components/blob/master/.github/workflows/pull-request.yml"

    %% Component-specific GraphQL
    subgraph "Component Queries & Mutations"
        direction TB
        BBQ["BuyButton Queries"]:::code
        BBM["BuyButton Mutations"]:::code
        GRQ["Greeting Queries"]:::code
        NLM["Newsletter Mutations"]:::code
        SSQ["ShippingSimulator Queries"]:::code
    end

    ReactComp --> BBQ
    ReactComp --> BBM
    ReactComp --> GRQ
    ReactComp --> NLM
    ReactComp --> SSQ

    click BBQ "https://github.com/vtex-apps/store-components/tree/master/react/components/BuyButton/queries/"
    click BBM "https://github.com/vtex-apps/store-components/tree/master/react/components/BuyButton/mutations/"
    click GRQ "https://github.com/vtex-apps/store-components/tree/master/react/components/Greeting/queries/"
    click NLM "https://github.com/vtex-apps/store-components/tree/master/react/components/Newsletter/mutations/"
    click SSQ "https://github.com/vtex-apps/store-components/tree/master/react/components/ShippingSimulator/queries/"

    %% Styles details
    subgraph "Global & Local Styles"
        direction TB
        GlobalCSS["Global *.css"]:::code
        LocalCSS["Component Styles"]:::code
        CSSHandles["CSS Handles TS"]:::code
    end

    Styles --> GlobalCSS
    Styles --> LocalCSS
    Styles --> CSSHandles

    click GlobalCSS "https://github.com/vtex-apps/store-components/blob/master/react/AutocompleteResults.css"
    click LocalCSS "https://github.com/vtex-apps/store-components/blob/master/react/components/BuyButton/styles.css"
    click CSSHandles "https://github.com/vtex-apps/store-components/blob/master/react/components/ProductBrand/ProductBrandCssHandles.ts"
    click CSSHandles "https://github.com/vtex-apps/store-components/blob/master/react/components/SKUSelector/SKUSelectorCssHandles.ts"
    click CSSHandles "https://github.com/vtex-apps/store-components/blob/master/react/components/SearchBar/SearchBarCssHandles.ts"
    click CSSHandles "https://github.com/vtex-apps/store-components/blob/master/react/components/UserAddress/UserAddressCssHandles.ts"

    %% Documentation
    Docs["Component Docs (docs/*.md)"]:::doc
    subgraph "Documentation"
        Docs
    end
    click Docs "https://github.com/vtex-apps/store-components/tree/master/docs/"

    %% Classes
    classDef code fill:#ADD8E6,stroke:#0366d6,color:#000
    classDef build fill:#98FB98,stroke:#228B22,color:#000
    classDef runtime fill:#FFA500,stroke:#CC8400,color:#000
    classDef test fill:#DDA0DD,stroke:#9932CC,color:#000
    classDef app fill:#E0FFFF,stroke:#20B2AA,color:#000
    classDef config fill:#F0E68C,stroke:#BDB76B,color:#000
    classDef doc fill:#D3D3D3,stroke:#A9A9A9,color:#000
```
