# digdir/designsystemet architecture

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

- Interactive diagram: https://gitdiagram.com/digdir/designsystemet
- Repository: https://github.com/digdir/designsystemet

## Overview

##### Main Architecture Components

a) Core Packages Layer:
- React Components (@digdir/designsystemet-react)
- CSS Styles (@digdir/designsystemet-css)
- Theming System (@digdir/designsystemet-theme)
- CLI Tools (@digdir/designsystemet)

b) Applications Layer:
- Storybook (Component Documentation)
- Storefront (General Documentation)
- Theme Builder
- Development App

c) Design Tokens Layer:
- Base Tokens
- Brand-specific Tokens
- Viewport-specific Tokens

##### Relationships and Flow

a) Design Token Flow:
**Design Tokens → CLI Build Process → CSS Theme Files → Components**

b) Component Implementation Flow:
**React Components ←→ CSS Styles ←→ Theme System**

c) Documentation Flow:
**Components → Storybook**
**Documentation → Storefront**
**Theme System → Theme Builder**

##### Detailed Component Structure

- Component hierarchy
- Shared utilities and hooks
- Form components
- Typography system
- Layout components

##### Implementation Details

Technical annotations for:
- CSS implementation approach
- Theme customization flow
- Component composition patterns
- Build and deployment processes

##### Integration Points

Highlight:
- Figma integration via Token Studio
- Custom theme creation workflow
- Font system integration
- TypeScript type generation

##### The build and deployment pipeline

This system design should reflect both the technical architecture and the user-facing aspects of the design system, making it valuable for both developers and designers.

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Styles and Classes
    classDef core fill:#e1f5fe,stroke:#01579b
    classDef app fill:#e8f5e9,stroke:#1b5e20
    classDef token fill:#f3e5f5,stroke:#4a148c
    classDef cli fill:#fff3e0,stroke:#e65100
    
    %% Design Tokens Layer
    subgraph Tokens
        BaseTokens["Base Tokens"]:::token
        BrandTokens["Brand Tokens"]:::token
        ViewportTokens["Viewport Tokens"]:::token
    end

    %% Core Packages Layer
    subgraph CorePackages
        ReactComponents["React Components"]:::core
        CSSStyles["CSS Styles"]:::core
        ThemeSystem["Theme System"]:::core
        CLITools["CLI Tools"]:::cli
    end

    %% Applications Layer
    subgraph Apps
        Storybook["Storybook Documentation"]:::app
        Storefront["Storefront Documentation"]:::app
        ThemeBuilder["Theme Builder"]:::app
        DevApp["Development App"]:::app
    end

    %% Relationships
    BaseTokens --> CLITools
    BrandTokens --> CLITools
    ViewportTokens --> CLITools
    CLITools --> CSSStyles
    CSSStyles <--> ReactComponents
    ThemeSystem <--> ReactComponents
    ThemeSystem <--> CSSStyles
    ReactComponents --> Storybook
    ReactComponents --> DevApp
    ThemeSystem --> ThemeBuilder
    
    %% Click Events
    click ReactComponents "https://github.com/digdir/designsystemet/tree/main/packages/react"
    click CSSStyles "https://github.com/digdir/designsystemet/tree/main/packages/css"
    click ThemeSystem "https://github.com/digdir/designsystemet/tree/main/packages/theme"
    click CLITools "https://github.com/digdir/designsystemet/tree/main/packages/cli"
    click Storybook "https://github.com/digdir/designsystemet/tree/main/apps/storybook"
    click Storefront "https://github.com/digdir/designsystemet/tree/main/apps/storefront"
    click ThemeBuilder "https://github.com/digdir/designsystemet/tree/main/apps/theme"
    click DevApp "https://github.com/digdir/designsystemet/tree/main/apps/dev"
    click BaseTokens "https://github.com/digdir/designsystemet/tree/main/design-tokens/Base"
    click BrandTokens "https://github.com/digdir/designsystemet/tree/main/design-tokens/Brand"
    click ViewportTokens "https://github.com/digdir/designsystemet/tree/main/design-tokens/Viewport"

    %% Legend
    subgraph Legend
        CoreLegend["Core Packages"]:::core
        AppLegend["Applications"]:::app
        TokenLegend["Design Tokens"]:::token
        CLILegend["CLI Tools"]:::cli
    end
```
