# umijs/qiankun architecture

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

- Interactive diagram: https://gitdiagram.com/umijs/qiankun
- Repository: https://github.com/umijs/qiankun

## Overview

##### Project type and purpose
- Qiankun is an open-source micro-frontend framework (based on single-spa) designed to enable independent deployment, runtime sandboxing, style isolation, asset prefetching, and HTML-entry integration of multiple “micro-apps” within a single host (shell) application.
- It is organized as a monorepo containing multiple packages: the core runtime (`qiankun`), HTML & JS loader (`@qiankunjs/loader`), JS sandbox (`@qiankunjs/sandbox`), shared utilities (`@qiankunjs/shared`), UI-bindings for React & Vue (`@qiankunjs/react`, `@qiankunjs/vue`, `@qiankunjs/ui-shared`), a webpack plugin (`@qiankunjs/webpack-plugin`), and a scaffolding tool (`create-qiankun`).

##### File structure
- Top-level “packages” folder contains each logical component (core, loader, sandbox, shared, ui-bindings, webpack-plugin, create-qiankun).
- Each package has its own source code, build config (`.fatherrc.js`), tests, and README.
- “examples” folder demonstrates a shell app plus multiple framework-specific micro-apps (Angular, React, Vue, Vite, etc.) to showcase integration.
- “docs” folder holds documentation powered by VitePress/dumi.
- Monorepo is orchestrated via pnpm workspace, with linting, formatting, CI workflows, and release automation configured at the root.

##### README for additional insights
- Qiankun core exposes APIs: `registerMicroApps`, `loadMicroApp`, `start`, `isRuntimeCompatible`, and lifecycle hooks.
- Features: HTML-entry access mode (loader), JS sandbox (compartmentalized execution), style isolation.
- Integrations: Umi plugin, CLI scaffolder (`create-qiankun`), webpack plugin for auto-public-path.

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "Monorepo"
        subgraph "Packages"
            subgraph "Runtime Modules"
                core["Qiankun Core Runtime"]:::runtime
                loader["HTML-entry Loader"]:::runtime
                sandbox["JS Sandbox"]:::runtime
            end
            shared["Shared Utilities"]:::util
            subgraph "UI Bindings"
                reactUI["React Binding"]:::ui
                vueUI["Vue Binding"]:::ui
            end
            webpack["Webpack Plugin"]:::build
            cli["CLI Scaffolder"]:::build
        end
    end

    shell["Shell App"]:::external
    microapps["Micro-Apps"]:::external

    shell -->|"registerMicroApps_and_start()"| core
    core -->|"fetch_and_parse_HTML"| loader
    loader -->|"execute_in_compartment"| sandbox
    sandbox -->|"mount_unmount_hooks"| reactUI
    sandbox -->|"mount_unmount_hooks"| vueUI
    reactUI -->|"load_bundles"| microapps
    vueUI -->|"load_bundles"| microapps
    microapps -->|"load_from_CDN_or_shared"| externalServices["External Services/CDNs"]:::external
    shared -->|"provide_utilities"| core
    shared -->|"provide_utilities"| loader
    shared -->|"provide_utilities"| sandbox
    webpack -->|"inject_runtime_publicPath"| core
    cli -->|"scaffold_shell_and_apps"| shell

    click core "https://github.com/umijs/qiankun/blob/next/packages/qiankun/src/index.ts"
    click loader "https://github.com/umijs/qiankun/blob/next/packages/loader/src/index.ts"
    click sandbox "https://github.com/umijs/qiankun/blob/next/packages/sandbox/src/index.ts"
    click shared "https://github.com/umijs/qiankun/blob/next/packages/shared/src/index.ts"
    click reactUI "https://github.com/umijs/qiankun/blob/next/packages/ui-bindings/react/src/index.ts"
    click vueUI "https://github.com/umijs/qiankun/blob/next/packages/ui-bindings/vue/src/index.ts"
    click webpack "https://github.com/umijs/qiankun/blob/next/packages/webpack-plugin/src/index.ts"
    click cli "https://github.com/umijs/qiankun/blob/next/packages/create-qiankun/src/index.ts"

    classDef runtime fill:#D0E8FF,stroke:#0366d6,color:#0366d6;
    classDef build fill:#E6FFE6,stroke:#28a745,color:#28a745;
    classDef util fill:#FFF9C4,stroke:#FBC02D,color:#F57F17;
    classDef ui fill:#FCE4EC,stroke:#D81B60,color:#880E4F;
    classDef external fill:#F0F0F0,stroke:#888888,color:#333333;
```
