# salesforce-ux/design-system architecture

> Architecture diagram of the GitHub repository salesforce-ux/design-system, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-03-29). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/salesforce-ux/design-system
- Repository: https://github.com/salesforce-ux/design-system

## Overview

##### Main Components
- Design Tokens & Themes:
– Indicate that these tokens provide the foundation for styling, reused across components.
- UI Components:
– Represent the vast “ui” directory (and “ui/components”) that holds React components, SCSS files, and stories (also seen in components like buttons, alerts, modals, etc.).
– Also include the “shared” and “touch” directories for components that have specialized functionality.
- Utilities and Helpers:
– Highlight the “utilities” directory (for alignment, spacing, text, etc.) that offers helper classes and functions.
– Note additional helper modules found under “shared/utils” and “ui/shared”.
- Build, Linting, and Automation Tools:
– Represent the “scripts” and “gulpfile.js” nodes. These run tasks such as compiling Sass (found in “scripts/compile”), linting, generating documentation, and releasing builds.
– Include CI/CD configuration (GitHub workflows, Travis scripts, and Heroku deployment files such as Procfile).
- Documentation, Guidelines, and Testing:
– Show a component for “Guidelines & Documentation” (e.g., the “guidelines” folder, README files, annotations guides, and troubleshooting documents).
– Represent testing (unit tests in “__tests__”, accessibility testing with aXe – seen in the gulp tasks, and Storybook integration that provides a live development environment).

##### Interactions and Relationships
- Data Flow & Dependency:
– Link Build Tools (Gulp, scripts) to components and tokens, showing that they compile, lint, and bundle assets.
– Show how CI/CD pipelines (Travis, GitHub actions) monitor changes in the repository and trigger tasks (tests, linting, builds).
– Connect the Storybook environment (launched via npm start) to the UI Components and Documentation to represent component development and preview.
- Modular & Layered Architecture:
– Use distinct modules (or layers) separated by responsibility: Foundation layer (tokens/themes and base styles), UI/building blocks layer (React components), and the tooling layer (automation scripts, testing, and release pipelines).

##### Architectural Patterns & Design Principles
- Component-Driven Design:
– Emphasize that UI components are isolated, reusable building blocks (as evident from the many component folders and Storybook stories).
- Separation of Concerns:
– Clearly separate style tokens, component code, and build/test scripts.
- Automated Build and Test:
– Highlight the integration of automated linting, tests (including accessibility and unit tests), and continuous integration via scripts and CI configuration files.

##### Technologies & Ecosystem
- Mention key technologies such as:
– React (for building UI components)
– Sass/SCSS (for styling)
– Gulp (for build tasks)
– Storybook (for component development)
– Node.js (with npm and nvm configurations, as noted by the .nvmrc file)
– YAML (for design tokens)
– Testing libraries like Jest and Axe for accessibility tests.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Foundation Layer
    subgraph "Foundation Layer"
        DT["Design Tokens & Themes"]:::foundation
    end

    %% UI Components Layer
    subgraph "UI Components Layer"
        UIR["React Components & SCSS (ui)"]:::ui
        UIC["Component Library (ui/components)"]:::ui
        UIT["Touch Components (ui/touch)"]:::ui
        UIS["Shared UI Components (ui/shared)"]:::ui
        USC["Shared Components (shared/components)"]:::ui
    end

    %% Utilities and Helpers Layer
    subgraph "Utilities Layer"
        UTIL["General Utilities (ui/utilities)"]:::utility
        USU["Additional Helpers (shared/utils)"]:::utility
    end

    %% Tooling & Automation Layer
    subgraph "Tooling & Automation Layer"
        SCRIPTS["Automation Scripts (scripts/)"]:::tool
        GULP["Gulp Tasks (gulpfile.js)"]:::tool
        CI["CI/CD Pipelines - Workflows (.github/workflows/)"]:::tool
        CI_A["CI/CD Pipelines - Actions (.github/actions/)"]:::tool
        STORY["Storybook Environment"]:::tool
    end

    %% Documentation & Testing Layer
    subgraph "Documentation & Testing"
        DOC["Guidelines & Documentation (guidelines/)"]:::doc
        TEST["Automated Tests (__tests__)"]:::doc
    end

    %% Relationships
    DT -->|"defines"| UIR
    DT -->|"defines"| UTIL

    UIR -->|"composes"| UIC
    UIR -->|"integrates"| UIT
    UIR -->|"augmented-by"| UIS
    UIR -->|"augmented-by"| USC

    UTIL -->|"assists"| UIR
    USU -->|"assists"| UIR

    SCRIPTS -->|"compiles"| UIR
    SCRIPTS -->|"processes"| DT
    SCRIPTS -->|"runs"| TEST

    GULP -->|"executes"| SCRIPTS

    CI -->|"triggers"| SCRIPTS
    CI_A -->|"triggers"| SCRIPTS

    STORY -->|"previews"| UIR
    STORY -->|"integrates-with"| DOC

    DOC -->|"documents"| UIR
    DOC -->|"references"| DT
    TEST -->|"validates"| UIR

    %% Click Events
    click DT "https://github.com/salesforce-ux/design-system/tree/main/design-tokens/"
    click UIR "https://github.com/salesforce-ux/design-system/tree/main/ui/"
    click UIC "https://github.com/salesforce-ux/design-system/tree/main/ui/components/"
    click UIT "https://github.com/salesforce-ux/design-system/tree/main/ui/touch/"
    click UIS "https://github.com/salesforce-ux/design-system/tree/main/ui/shared/"
    click USC "https://github.com/salesforce-ux/design-system/tree/main/shared/components/"
    click UTIL "https://github.com/salesforce-ux/design-system/tree/main/ui/utilities/"
    click USU "https://github.com/salesforce-ux/design-system/tree/main/shared/utils/"
    click SCRIPTS "https://github.com/salesforce-ux/design-system/tree/main/scripts/"
    click GULP "https://github.com/salesforce-ux/design-system/blob/main/gulpfile.js"
    click CI "https://github.com/salesforce-ux/design-system/tree/main/.github/workflows/"
    click CI_A "https://github.com/salesforce-ux/design-system/tree/main/.github/actions/"
    click DOC "https://github.com/salesforce-ux/design-system/tree/main/guidelines/"
    click TEST "https://github.com/salesforce-ux/design-system/tree/main/__tests__/"

    %% Styles
    classDef foundation fill:#f9e79f,stroke:#b9770e,stroke-width:2px;
    classDef ui fill:#aed6f1,stroke:#2471a3,stroke-width:2px;
    classDef utility fill:#fadbd8,stroke:#d35400,stroke-width:2px;
    classDef tool fill:#d5f5e3,stroke:#229954,stroke-width:2px;
    classDef doc fill:#fcf3cf,stroke:#b7950b,stroke-width:2px;
```
