# tusen-ai/naive-ui architecture

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

- Interactive diagram: https://gitdiagram.com/tusen-ai/naive-ui
- Repository: https://github.com/tusen-ai/naive-ui

## Overview

##### Project type and purpose
- This is a Vue 3 UI Component Library (“Naive UI”) written in TypeScript.
- It also includes a live documentation/demo site, playground tests, and a full build & release pipeline.

##### File structure
- Top‐level:
- build/ & scripts/ – custom Vite plugins, webpack loaders, bundling helpers, post/pre build scripts
- demo/ – documentation site built with Vite/Vue using markdown→Vue loaders under build/loaders
- playground/ – manual test apps (SSR, upload server, async validator demos)
- .github/workflows/ – CI definitions (Node.js tests, build checks, lint, publish)
- config files – babel.config.js, rollup.config.js, vite.config.js, tsconfig*, jest.config.js, eslint.config.mjs
- package.json, CHANGELOG, CONTRIBUTING, README – project metadata and instructions
- themes/ – example theme override packages

##### README for additional insights
- Confirms:
- Vue 3 component library
- Theme overrides with no extra CSS toolchains
- Documentation hosted at www.naiveui.com
- CI publishes to npm registry and OSS CDN for static assets

##### Detail & thoroughness
- Essential folder’s role (src, demo, build, scripts, playground)
- Don’t overcomplicate: isolate major components and their interactions
- Flows (development → build → test → publish → consume) are visible

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "Component Source"
        SRC["src/\\nComponents, _internal, _mixins, _utils, _styles, locales"]:::source
    end

    subgraph "Documentation / Demo Site"
        DEMO["demo/"]:::source
        LOADERS["build/loaders/"]:::source
        PAGES["demo/pages/"]:::source
    end

    subgraph "Build Pipeline"
        BUILD["build/"]:::build
        SCRIPTS["scripts/"]:::build
        ROLLUP["rollup.config.js"]:::build
        VITECFG["vite.config.js"]:::build
        BABEL["babel.config.js"]:::build
        TSCONFIG["tsconfig.*.json"]:::build
    end

    subgraph "Playground / Manual Tests"
        PG["playground/"]:::source
        PSSR["playground/ssr/"]:::source
    end

    subgraph "CI/CD"
        CI[".github/workflows/node.js.yml"]:::ci
        RELCHG["scripts/release-changelog.mjs"]:::ci
        POSTSITE["scripts/post-build-site/"]:::ci
    end

    subgraph "Themes / Overrides"
        THEMES["themes/"]:::source
        STYLES["src/_styles/"]:::source
        USETHEME["src/_mixins/use-theme.ts"]:::source
    end

    subgraph "Distribution Artifacts"
        DIST["dist/"]:::artifact
        TYPES["types/"]:::artifact
    end

    subgraph "Consumers & External Services"
        PKG["package.json"]:::external
        NPMRC[".npmrc"]:::external
        READMES["README.md / CHANGELOG*.md"]:::external
        NPM["npm registry"]:::external
        CDN["OSS CDN"]:::external
        USERS["End-users (Vue 3 apps)"]:::external
        VISITORS["Documentation site visitors"]:::external
    end

    SRC --> BUILD
    BUILD --> DIST
    BUILD --> TYPES
    SRC --> DEMO
    LOADERS --> DEMO
    PAGES --> DEMO
    CI --> BUILD
    CI --> DEMO
    CI --> PG
    CI --> DIST
    CI --> NPM
    DIST --> NPM
    NPM --> USERS
    CDN --> DEMO
    USERS -->|install| NPM
    THEMES --> STYLES
    THEMES --> USETHEME
    STYLES --> BUILD
    USETHEME --> BUILD

    click SRC "https://github.com/tusen-ai/naive-ui/tree/main/src/"
    click BUILD "https://github.com/tusen-ai/naive-ui/tree/main/build/"
    click SCRIPTS "https://github.com/tusen-ai/naive-ui/tree/main/scripts/"
    click ROLLUP "https://github.com/tusen-ai/naive-ui/blob/main/rollup.config.js"
    click VITECFG "https://github.com/tusen-ai/naive-ui/blob/main/vite.config.js"
    click BABEL "https://github.com/tusen-ai/naive-ui/blob/main/babel.config.js"
    click TSCONFIG "https://github.com/tusen-ai/naive-ui/blob/main/tsconfig.*.json"
    click DEMO "https://github.com/tusen-ai/naive-ui/tree/main/demo/"
    click LOADERS "https://github.com/tusen-ai/naive-ui/tree/main/build/loaders/"
    click PAGES "https://github.com/tusen-ai/naive-ui/tree/main/demo/pages/"
    click PG "https://github.com/tusen-ai/naive-ui/tree/main/playground/"
    click PSSR "https://github.com/tusen-ai/naive-ui/tree/main/playground/ssr/"
    click CI "https://github.com/tusen-ai/naive-ui/blob/main/.github/workflows/node.js.yml"
    click RELCHG "https://github.com/tusen-ai/naive-ui/blob/main/scripts/release-changelog.mjs"
    click POSTSITE "https://github.com/tusen-ai/naive-ui/tree/main/scripts/post-build-site/"
    click THEMES "https://github.com/tusen-ai/naive-ui/tree/main/themes/"
    click STYLES "https://github.com/tusen-ai/naive-ui/tree/main/src/_styles/"
    click USETHEME "https://github.com/tusen-ai/naive-ui/blob/main/src/_mixins/use-theme.ts"

    classDef source fill:#85C1E9,stroke:#1B4F72,color:#FFFFFF;
    classDef build fill:#82E0AA,stroke:#1D8348,color:#FFFFFF;
    classDef ci fill:#F5B041,stroke:#B9770E,color:#FFFFFF;
    classDef artifact fill:#BB8FCE,stroke:#6C3483,color:#FFFFFF;
    classDef external fill:#CACFD2,stroke:#566573,color:#000000;
```
