# jd-opensource/taro-ui architecture

> Architecture diagram of the GitHub repository jd-opensource/taro-ui, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-07-17). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/jd-opensource/taro-ui
- Repository: https://github.com/jd-opensource/taro-ui

## Overview

##### Project type and purpose
- This is a monorepo for “Taro UI,” a multi-platform UI component library built on the Taro framework.
- It provides:
- Core component source (packages/taro-ui/src)
- Platform-specific builds (packages/taro-ui/rn for React Native)
- Demo applications (packages/taro-ui-demo, packages/taro-ui-demo-rn, examples/)
- Documentation site (packages/taro-ui-docs)
- The README confirms it’s an open-source, multi-target UI toolkit, not a typical full-stack app.

##### File structure
- Top-level: configuration files (.eslintrc, babel.config.json, CI workflows), examples, and a PNPM workspace descriptor.
- “packages/” contains four main packages:
- taro-ui: the core library (TypeScript source + rollup configs + tests)
- taro-ui/rn: React Native flavor of the core
- taro-ui-demo: H5/Mini-app demo
- taro-ui-demo-rn: RN demo
- taro-ui-docs: documentation site built with webpack
- “examples/” holds minimal sample projects illustrating usage (one for Sass version, one for lazy-load component).
- Build/CI scripts: rollup configs, webpack configs in docs, GitHub Actions and Travis workflows for test/build/publish.

##### README for additional insights
- Confirms multi-end support: WeChat/Alipay/Baidu mini-apps, H5, React Native.
- Mentions Taro’s compile-to-multiple-targets pipeline.
- Points to separate docs site and official demos.

##### Detail
- Package as a separate node.
- How shared configs (.eslintrc, babel.config.json) flow into each package build.
- Test runner stage for the core package.
- Multi-platform compile targets.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Monorepo Root
    subgraph "Monorepo Root"
        Workspace["pnpm-workspace.yaml"] 
        RootPkg["package.json"]
        ESLint[".eslintrc.json"]
        BabelCfg["babel.config.json"]
        GHWF_Root[".github/workflows/"]
        Travis_Root[".travis.yml"]
    end

    %% Core UI Library
    subgraph "Core UI Library" 
        CoreSrc["packages/taro-ui/src/"]
        CoreRollup["packages/taro-ui/config/rollup.config.js"]
        CorePkg["packages/taro-ui/package.json"]
        CoreTest["packages/taro-ui/test/"]
        CoreTS["packages/taro-ui/tsconfig.json"]
    end

    %% React Native Adapter
    subgraph "RN Adapter"
        RnDir["packages/taro-ui/rn/"]
        RnIndex["packages/taro-ui/rn/index.ts"]
        RnCommon["packages/taro-ui/rn/common/"]
        RnComp["packages/taro-ui/rn/components/"]
        RnStyle["packages/taro-ui/rn/style/"]
    end

    %% H5 / Mini-app Demo
    subgraph "H5 / Mini-app Demo"
        H5Dir["packages/taro-ui-demo/"]
        H5Src["packages/taro-ui-demo/src/"]
        H5Cfg["packages/taro-ui-demo/config/"]
        H5Pkg["packages/taro-ui-demo/package.json"]
    end

    %% React Native Demo
    subgraph "RN Demo"
        RnDemoDir["packages/taro-ui-demo-rn/"]
        RnDemoSrc["packages/taro-ui-demo-rn/src/"]
        RnDemoCfg["packages/taro-ui-demo-rn/config/"]
        RnDemoMetro["packages/taro-ui-demo-rn/metro.config.js"]
        RnDemoPkg["packages/taro-ui-demo-rn/package.json"]
    end

    %% Documentation Site
    subgraph "Documentation Site"
        DocsDir["packages/taro-ui-docs/"]
        DocsWebpack["packages/taro-ui-docs/build/webpack.prod.config.js"]
        DocsPages["packages/taro-ui-docs/pages/"]
        DocsComps["packages/taro-ui-docs/components/"]
        DocsMD["packages/taro-ui-docs/markdown/"]
        DocsPkg["packages/taro-ui-docs/package.json"]
    end

    %% Examples
    subgraph Examples
        SassEx["examples/about-sass-version/"]
        LazyEx["examples/lazy-load-component/"]
    end

    %% CI/CD Pipelines
    subgraph "CI/CD Pipelines"
        GH_Node[".github/workflows/node.yml"]
        GH_Publish[".github/workflows/publish.yml"]
        GH_RN[".github/workflows/rn-release.yml"]
        GH_TCB[".github/workflows/deploy-tcb.yml"]
        TravisCI[".travis.yml"]
    end

    %% External
    NPM["NPM Registry"]:::external
    TaroCLI["Taro CLI"]:::tool
    Rollup["Rollup"]:::tool
    Webpack["Webpack"]:::tool
    BabelMetro["Babel + Metro"]:::tool

    %% Relationships
    Workspace -->|"manages"| CoreSrc
    RootPkg -->|workspace| CoreSrc
    ESLint -->|configures| CoreSrc
    BabelCfg -->|transpilation| CoreSrc

    CoreSrc -->|"bundled by"| Rollup
    CoreRollup -->|config| Rollup
    Rollup -->|output| CorePkg
    Rollup -->|builds| RnDir
    CoreSrc -->|compiled by Taro CLI| H5Dir
    CoreSrc -->|"consumed by"| RnDir

    RnDir -->|adapter code| RnIndex
    RnIndex -->|imports common| RnCommon
    RnIndex -->|imports components| RnComp

    H5Dir -->|demo code| H5Src
    H5Src -->|uses Taro CLI| TaroCLI

    RnDemoDir -->|demo code| RnDemoSrc
    RnDemoSrc -->|uses Babel + Metro| BabelMetro

    DocsDir -->|site generation| Webpack
    DocsWebpack -->|config| Webpack
    DocsPages -->|content| Webpack
    DocsComps -->|UI| Webpack
    DocsMD -->|markdown| Webpack

    GH_Node -->|runs tests| CoreTest
    GH_Node -->|builds| CoreSrc
    GH_Publish -->|publishes| NPM
    GH_RN -->|releases RN| NPM
    GH_TCB -->|deploy docs| DocsDir
    TravisCI -->|CI for all| CoreSrc

    %% Flows
    Rollup -->|publish| NPM
    Webpack -->|deploy| DocsDir
    TaroCLI -->|compile| H5Dir

    %% Demo consumption
    H5Dir -->|demo| Examples
    RnDemoDir -->|demo| Examples

    %% Click Events
    click Workspace "https://github.com/jd-opensource/taro-ui/blob/next/pnpm-workspace.yaml"
    click RootPkg "https://github.com/jd-opensource/taro-ui/blob/next/package.json"
    click ESLint "https://github.com/jd-opensource/taro-ui/blob/next/.eslintrc.json"
    click BabelCfg "https://github.com/jd-opensource/taro-ui/blob/next/babel.config.json"
    click GHWF_Root "https://github.com/jd-opensource/taro-ui/tree/next/.github/workflows/"
    click Travis_Root "https://github.com/jd-opensource/taro-ui/blob/next/.travis.yml"

    click CoreSrc "https://github.com/jd-opensource/taro-ui/tree/next/packages/taro-ui/src/"
    click CoreRollup "https://github.com/jd-opensource/taro-ui/blob/next/packages/taro-ui/config/rollup.config.js"
    click CorePkg "https://github.com/jd-opensource/taro-ui/blob/next/packages/taro-ui/package.json"
    click CoreTest "https://github.com/jd-opensource/taro-ui/tree/next/packages/taro-ui/test/"
    click CoreTS "https://github.com/jd-opensource/taro-ui/blob/next/packages/taro-ui/tsconfig.json"

    click RnDir "https://github.com/jd-opensource/taro-ui/tree/next/packages/taro-ui/rn/"
    click RnIndex "https://github.com/jd-opensource/taro-ui/blob/next/packages/taro-ui/rn/index.ts"
    click RnCommon "https://github.com/jd-opensource/taro-ui/tree/next/packages/taro-ui/rn/common/"
    click RnComp "https://github.com/jd-opensource/taro-ui/tree/next/packages/taro-ui/rn/components/"
    click RnStyle "https://github.com/jd-opensource/taro-ui/tree/next/packages/taro-ui/rn/style/"

    click H5Dir "https://github.com/jd-opensource/taro-ui/tree/next/packages/taro-ui-demo/"
    click H5Src "https://github.com/jd-opensource/taro-ui/tree/next/packages/taro-ui-demo/src/"
    click H5Cfg "https://github.com/jd-opensource/taro-ui/tree/next/packages/taro-ui-demo/config/"
    click H5Pkg "https://github.com/jd-opensource/taro-ui/blob/next/packages/taro-ui-demo/package.json"

    click RnDemoDir "https://github.com/jd-opensource/taro-ui/tree/next/packages/taro-ui-demo-rn/"
    click RnDemoSrc "https://github.com/jd-opensource/taro-ui/tree/next/packages/taro-ui-demo-rn/src/"
    click RnDemoCfg "https://github.com/jd-opensource/taro-ui/tree/next/packages/taro-ui-demo-rn/config/"
    click RnDemoMetro "https://github.com/jd-opensource/taro-ui/blob/next/packages/taro-ui-demo-rn/metro.config.js"
    click RnDemoPkg "https://github.com/jd-opensource/taro-ui/blob/next/packages/taro-ui-demo-rn/package.json"

    click DocsDir "https://github.com/jd-opensource/taro-ui/tree/next/packages/taro-ui-docs/"
    click DocsWebpack "https://github.com/jd-opensource/taro-ui/blob/next/packages/taro-ui-docs/build/webpack.prod.config.js"
    click DocsPages "https://github.com/jd-opensource/taro-ui/tree/next/packages/taro-ui-docs/pages/"
    click DocsComps "https://github.com/jd-opensource/taro-ui/tree/next/packages/taro-ui-docs/components/"
    click DocsMD "https://github.com/jd-opensource/taro-ui/tree/next/packages/taro-ui-docs/markdown/"
    click DocsPkg "https://github.com/jd-opensource/taro-ui/blob/next/packages/taro-ui-docs/package.json"

    click SassEx "https://github.com/jd-opensource/taro-ui/tree/next/examples/about-sass-version/"
    click LazyEx "https://github.com/jd-opensource/taro-ui/tree/next/examples/lazy-load-component/"

    click GH_Node "https://github.com/jd-opensource/taro-ui/blob/next/.github/workflows/node.yml"
    click GH_Publish "https://github.com/jd-opensource/taro-ui/blob/next/.github/workflows/publish.yml"
    click GH_RN "https://github.com/jd-opensource/taro-ui/blob/next/.github/workflows/rn-release.yml"
    click GH_TCB "https://github.com/jd-opensource/taro-ui/blob/next/.github/workflows/deploy-tcb.yml"
    click TravisCI "https://github.com/jd-opensource/taro-ui/blob/next/.travis.yml"

    %% Styles
    classDef core fill:#FFD,stroke:#333,stroke-width:1px
    classDef adapter fill:#CFC,stroke:#333,stroke-width:1px
    classDef demo fill:#CCF,stroke:#333,stroke-width:1px
    classDef docs fill:#FCC,stroke:#333,stroke-width:1px
    classDef ci fill:#FCF,stroke:#333,stroke-width:1px
    classDef tool fill:#CFF,stroke:#333,stroke-width:1px
    classDef external fill:#EEE,stroke:#333,stroke-width:1px

    class CoreSrc,CoreRollup,CorePkg,CoreTest,CoreTS core
    class RnDir,RnIndex,RnCommon,RnComp,RnStyle adapter
    class H5Dir,H5Src,H5Cfg,H5Pkg,RnDemoDir,RnDemoSrc,RnDemoCfg,RnDemoMetro,RnDemoPkg demo
    class DocsDir,DocsWebpack,DocsPages,DocsComps,DocsMD,DocsPkg docs
    class GH_Node,GH_Publish,GH_RN,GH_TCB,TravisCI ci
    class TaroCLI,Rollup,Webpack,BabelMetro tool
    class NPM external
```
