# kong/design-tokens architecture

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

- Interactive diagram: https://gitdiagram.com/kong/design-tokens
- Repository: https://github.com/kong/design-tokens

## Overview

##### Component Details and Relationships

a. Token Management Layer:
**[Token Source Files] ─────┐**

**[Token Alias Files] ──────┼─→ [Style Dictionary Build System]**

**[Config Files] ───────────┘**

b. Distribution Layer:
- ┌─→ [SCSS Output]
- → [LESS Output]
**[Build System] ────→├─→ [CSS Custom Properties]**
- → [JavaScript/TypeScript]
- → [JSON Output]

c. Integration Layer:
- ┌─→ [Host Applications]
**[Output Formats] ──→├─→ [Standalone Components]**
- → [Development Sandbox]

##### Important Elements

- Token Directory Structure:
- /tokens
- /alias (Internal references)
- /source (Exportable tokens)
- /animation
- /border
- /components

- Build Process Flow:
- [Source Files] → [Style Dictionary] → [Platform Transforms] → [Dist Outputs]

- Integration Points:
- Stylelint Plugin connection
- VS Code Extension support
- Development Sandbox relationship

##### Additional Details

- A note about devDependency usage
- Package distribution flow
- Token validation and linting points

- Special indicators

This system design should emphasize the project's role as a design token management system that serves as a crucial part of Kong's design system infrastructure, highlighting both the build process and the consumption patterns.

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Styles and classes
    classDef source fill:#2196F3,stroke:#1565C0,color:white
    classDef alias fill:#42A5F5,stroke:#1976D2,color:white
    classDef build fill:#4CAF50,stroke:#388E3C,color:white
    classDef output fill:#FF9800,stroke:#F57C00,color:white
    classDef integration fill:#9C27B0,stroke:#7B1FA2,color:white
    classDef cicd fill:#607D8B,stroke:#455A64,color:white
    classDef utils fill:#795548,stroke:#5D4037,color:white

    subgraph TokenManagement["Token Management Layer"]
        SourceFiles["Token Source Files"]:::source
        AliasFiles["Token Alias Files"]:::alias
        Config["Build Config"]:::build
    end

    subgraph BuildSystem["Build & Transform Layer"]
        StyleDict["Style Dictionary Build System"]:::build
        Utils["Utility Functions"]:::utils
    end

    subgraph OutputFormats["Distribution Layer"]
        SCSS["SCSS Output"]:::output
        LESS["LESS Output"]:::output
        CSS["CSS Custom Properties"]:::output
        JS["JavaScript/TypeScript"]:::output
        JSON["JSON Output"]:::output
    end

    subgraph Integration["Integration Layer"]
        StyleLint["Stylelint Plugin"]:::integration
        DevSandbox["Development Sandbox"]:::integration
        VSCode["VS Code Extension"]:::integration
    end

    subgraph CICD["CI/CD Layer"]
        GHActions["GitHub Actions"]:::cicd
        SemanticRelease["Semantic Release"]:::cicd
    end

    %% Relationships
    SourceFiles --> StyleDict
    AliasFiles --> StyleDict
    Config --> StyleDict
    Utils --> StyleDict

    StyleDict --> SCSS
    StyleDict --> LESS
    StyleDict --> CSS
    StyleDict --> JS
    StyleDict --> JSON

    OutputFormats --> StyleLint
    OutputFormats --> DevSandbox
    OutputFormats --> VSCode

    StyleDict --> GHActions
    GHActions --> SemanticRelease

    %% Click events
    click SourceFiles "https://github.com/Kong/design-tokens/tree/main/tokens/source"
    click AliasFiles "https://github.com/Kong/design-tokens/tree/main/tokens/alias"
    click Config "https://github.com/Kong/design-tokens/blob/main/config.mjs"
    click Utils "https://github.com/Kong/design-tokens/tree/main/utilities"
    click SCSS "https://github.com/Kong/design-tokens/blob/main/platforms/scss.mjs"
    click LESS "https://github.com/Kong/design-tokens/blob/main/platforms/less.mjs"
    click CSS "https://github.com/Kong/design-tokens/blob/main/platforms/css.mjs"
    click JS "https://github.com/Kong/design-tokens/blob/main/platforms/javascript.mjs"
    click JSON "https://github.com/Kong/design-tokens/blob/main/platforms/json.mjs"
    click StyleLint "https://github.com/Kong/design-tokens/tree/main/stylelint-plugin"
    click DevSandbox "https://github.com/Kong/design-tokens/tree/main/sandbox"
    click GHActions "https://github.com/Kong/design-tokens/tree/main/.github/workflows"

    %% Legend
    subgraph Legend
        L1["Source Components"]:::source
        L2["Alias Components"]:::alias
        L3["Build Components"]:::build
        L4["Output Formats"]:::output
        L5["Integration Points"]:::integration
        L6["CI/CD Components"]:::cicd
        L7["Utilities"]:::utils
    end
```
