# douyinfe/semi-design architecture

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

- Interactive diagram: https://gitdiagram.com/douyinfe/semi-design
- Repository: https://github.com/douyinfe/semi-design

## Overview

This project is a large-scale monorepo for Semi‑UI – a modern design system and comprehensive React component library that connects design with development. Its architecture is split into multiple packages (via a Lerna-managed monorepo), a documentation and demo site, and various tooling integrations (testing, build scripts, Storybook, Figma integration, etc).

##### Overview and layers
- At the top level, identify the “Design System” and “Component Library” domain. Highlight that the project supports both design tokens (DSM), design-to-code, and extensive testing/devops capabilities.

##### Main components
a. Core UI Libraries and Foundations:
- “semi-ui”: The main component library containing the React components and their demos.
- “semi-foundation”: Provides design tokens, CSS/SCSS styling foundations, theming and variables used by many components.
- “semi-animation” (including its variants such as semi-animation-react and semi-animation-styled): These packages give the library its animation features.
b. Tooling & Build Ecosystem:
- Other packages such as “semi-eslint-plugin”, “semi-rspack”, “semi-scss-compile”, and “semi-webpack”. These encapsulate build configuration, linting, CSS compilation and bundling solutions.
- Utility packages like “semi-json-viewer-core” provide specific functionality.
c. Documentation & Demos:
- The “src” folder contains documentation, demo pages (using Gatsby) and live examples.
- Storybook configuration (in .storybook) and codesandbox examples to show interactive component demos.
d. Testing and CI/CD:
- Directories for Jest tests, Cypress end-to-end testing (cypress/), and GitHub workflow configurations.
- Tools like Chromatic are integrated for visual regression testing.
e. External Integration:
- Figma plugin for design‑to‑code and DSM support.
- References to design token tools and external testing platforms (Cypress, Chromatic).
- The site’s pages (Gatsby) for documentation and component demos.

##### Establish the relationships and interactions
- The “semi-ui” library depends on “semi-foundation” for consistent styling and theming.
- The animation packages provide effect modules that can be optionally used by UI components.
- Build and tooling packages (eslint plugin, webpack, scss-compile) are integrated into the CI/CD pipelines and the overall development workflow (as seen via the GitHub workflows, lerna.json, and build scripts).
- The Demo Website (using Gatsby in the src folder) connects to all component packages; it also interacts with the design system documentation and live example demos.
- External testing platforms (Chromatic, Cypress) operate on the built artifacts from several packages.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Core Packages
    subgraph "Core Packages"
        UI["semi‑ui – React component library"]:::ui
        Found["semi‑foundation – Design tokens and CSS/SCSS styling"]:::foundation
        Anim["semi‑animation – Animation package"]:::ui
        AnimReact["semi‑animation‑react – React animations"]:::ui
        AnimStyled["semi‑animation‑styled – Styled animations"]:::ui
        Icons["semi‑icons – Icon library"]:::ui
        IconsLab["semi‑icons‑lab – Experimental icons"]:::ui
        Illus["semi‑illustrations – Illustration assets"]:::ui
    end

    %% Build & Tooling
    subgraph "Build & Tooling"
        ESLint["semi‑eslint‑plugin – Linting"]:::build
        Rspack["semi‑rspack – Bundling"]:::build
        SCSS["semi‑scss‑compile – CSS/SCSS compilation"]:::build
        Webpack["semi‑webpack – Webpack bundler"]:::build
        JSONViewer["semi‑json‑viewer‑core – Utility package"]:::build
    end

    %% Documentation & Demos
    subgraph "Documentation & Demos"
        Pages["Gatsby Pages – Documentation Site"]:::demo
        Demos["Gatsby Demos – Live Examples"]:::demo
        SitePages["Site Pages – Additional Docs"]:::demo
        Storybook["Storybook – Component demos"]:::demo
    end

    %% Testing & CI/CD
    subgraph "Testing & CI/CD"
        Jest["Jest – Unit Testing"]:::testing
        Cypress["Cypress – End‑to‑end Testing"]:::testing
        GitHub["GitHub Workflows – CI/CD Pipelines"]:::testing
    end

    %% External Integrations
    subgraph "External Integrations"
        Figma["Figma Plugin – Design‑to‑code integration"]:::external
        Chromatic["Chromatic – Visual regression testing"]:::external
    end

    %% Relationships within Core Packages
    UI -->|"depends_on"| Found
    UI -->|"uses"| Anim
    UI -->|"uses"| AnimReact
    UI -->|"uses"| AnimStyled
    UI -->|"imports"| Icons
    UI -->|"imports"| IconsLab
    UI -->|"imports"| Illus

    %% Documentation/Demos usage of core packages
    Pages -->|"demonstrates"| UI
    Pages -->|"uses"| Found
    Pages -->|"includes"| Icons
    Pages -->|"includes"| Illus
    Demos -->|"demonstrates"| UI
    SitePages -->|"documents"| UI
    Storybook -->|"displays"| UI

    %% Build & Tooling integration
    ESLint -->|"linting"| UI
    Rspack -->|"bundles"| UI
    SCSS -->|"compiles"| Found
    Webpack -->|"bundles"| UI
    JSONViewer -->|"provides_utilities_for"| UI

    %% Testing & CI/CD integration
    Jest -->|"tests"| UI
    Cypress -->|"tests_demos"| Pages
    GitHub -->|"orchestrates"| ESLint
    GitHub -->|"orchestrates"| Rspack
    GitHub -->|"orchestrates"| SCSS
    GitHub -->|"orchestrates"| Webpack

    %% External Integrations connections
    Figma -->|"syncs_with"| Found
    Figma -->|"influences"| UI
    Chromatic -->|"validates"| Cypress

    %% Class Definitions for styling
    classDef ui fill:#ADD8E6,stroke:#000,stroke-width:2px;
    classDef foundation fill:#90EE90,stroke:#000,stroke-width:2px;
    classDef build fill:#FFA500,stroke:#000,stroke-width:2px;
    classDef demo fill:#DDA0DD,stroke:#000,stroke-width:2px;
    classDef testing fill:#FF7F7F,stroke:#000,stroke-width:2px;
    classDef external fill:#FFFF99,stroke:#000,stroke-width:2px;

    %% Assign node classes
    class UI,Anim,AnimReact,AnimStyled,Icons,IconsLab,Illus ui;
    class Found foundation;
    class ESLint,Rspack,SCSS,Webpack,JSONViewer build;
    class Pages,Demos,SitePages,Storybook demo;
    class Jest,Cypress,GitHub testing;
    class Figma,Chromatic external;

    %% Click Events for Core Packages
    click UI "https://github.com/douyinfe/semi-design/tree/main/packages/semi‑ui"
    click Found "https://github.com/douyinfe/semi-design/tree/main/packages/semi‑foundation"
    click Anim "https://github.com/douyinfe/semi-design/tree/main/packages/semi‑animation"
    click AnimReact "https://github.com/douyinfe/semi-design/tree/main/packages/semi‑animation‑react"
    click AnimStyled "https://github.com/douyinfe/semi-design/tree/main/packages/semi‑animation‑styled"
    click Icons "https://github.com/douyinfe/semi-design/tree/main/packages/semi‑icons"
    click IconsLab "https://github.com/douyinfe/semi-design/tree/main/packages/semi‑icons‑lab"
    click Illus "https://github.com/douyinfe/semi-design/tree/main/packages/semi‑illustrations"

    %% Click Events for Build & Tooling
    click ESLint "https://github.com/douyinfe/semi-design/tree/main/packages/semi‑eslint‑plugin"
    click Rspack "https://github.com/douyinfe/semi-design/tree/main/packages/semi‑rspack"
    click SCSS "https://github.com/douyinfe/semi-design/tree/main/packages/semi‑scss‑compile"
    click Webpack "https://github.com/douyinfe/semi-design/tree/main/packages/semi‑webpack"
    click JSONViewer "https://github.com/douyinfe/semi-design/tree/main/packages/semi‑json‑viewer‑core"

    %% Click Events for Documentation & Demos
    click Pages "https://github.com/douyinfe/semi-design/tree/main/src/pages"
    click Demos "https://github.com/douyinfe/semi-design/tree/main/src/demos"
    click SitePages "https://github.com/douyinfe/semi-design/tree/main/src/sitePages"
    click Storybook "https://github.com/douyinfe/semi-design/blob/main/.storybook"

    %% Click Events for Testing & CI/CD
    click Jest "https://github.com/douyinfe/semi-design/blob/main/jest.config.js"
    click Cypress "https://github.com/douyinfe/semi-design/tree/main/cypress"
    click GitHub "https://github.com/douyinfe/semi-design/tree/main/.github/workflows"
```
