# ice-lab/icestark architecture

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

- Interactive diagram: https://gitdiagram.com/ice-lab/icestark
- Repository: https://github.com/ice-lab/icestark

## Overview

icestark is a framework-independent micro-frontend runtime: a main application registers sub-applications, matches navigation to them, loads their assets and lifecycles, and mounts or unmounts them. The repository also provides sub-application lifecycle and routing helpers, a module-loading API with sandbox support, and shared data utilities. The principal flow is supported by the README and sampled host-runtime excerpts; some subsystem details are represented at their source-directory level because their implementation was not sampled.

Main entry points: [`packages/icestark/src/apps.ts`](https://github.com/ice-lab/icestark/blob/master/packages/icestark/src/apps.ts) (App Registry), [`packages/icestark/src/AppRouter.tsx`](https://github.com/ice-lab/icestark/blob/master/packages/icestark/src/AppRouter.tsx) (App Router), [`packages/icestark-module/src/modules.tsx`](https://github.com/ice-lab/icestark/blob/master/packages/icestark-module/src/modules.tsx) (Module Registry), [`packages/icestark/src/start.ts`](https://github.com/ice-lab/icestark/blob/master/packages/icestark/src/start.ts) (Runtime Startup)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_host["Host Runtime"]
  node_router["App Router<br/>[AppRouter.tsx]"]
  node_route["App Route<br/>[AppRoute.tsx]"]
  node_history["App History<br/>[appHistory.ts]"]
  node_matcher["Active Path Matcher<br/>[checkActive.ts]"]
  node_registry["App Registry<br/>[apps.ts]"]
  node_startup["Runtime Startup<br/>[start.ts]"]
  node_configuration["Global Configuration"]
  node_prefetch["Asset Prefetch<br/>[prefetch.ts]"]
end

subgraph group_loading["Loading and Isolation"]
  node_asset["Asset Processing<br/>[handleAssets.ts]"]
  node_loader["Script Loaders<br/>[loaders.ts]"]
  node_lifecycle["Lifecycle Resolution<br/>[getLifecycle.ts]"]
  node_sandbox["JavaScript Sandbox<br/>[index.ts]"]
end

subgraph group_child["Sub-app Integration"]
  node_childsdk["Sub-app Helpers"]
  node_childlink["Sub-app Link<br/>[AppLink.tsx]"]
end

subgraph group_shared["Modules and Shared Data"]
  node_moduleapi["Module Registry<br/>[modules.tsx]"]
  node_moduleloader["Module Loader<br/>[loader.ts]"]
  node_runtime["Runtime Helpers<br/>[runtimeHelper.ts]"]
  node_datastore[("Shared Store<br/>[store.ts]")]
  node_events["Shared Events<br/>[event.ts]"]
end

node_main(("Main Application"))

node_main -->|"configures"| node_router
node_router -->|"renders"| node_route
node_router -->|"starts"| node_startup
node_router -->|"prefetches"| node_prefetch
node_route -->|"matches paths"| node_matcher
node_route -->|"registers app"| node_registry
node_main -->|"registers apps"| node_registry
node_main -->|"starts runtime"| node_startup
node_startup -->|"dispatches"| node_registry
node_registry -->|"checks activity"| node_matcher
node_registry -->|"parses assets"| node_asset
node_registry -->|"loads scripts"| node_loader
node_registry -->|"resolves lifecycle"| node_lifecycle
node_registry -->|"creates sandbox"| node_sandbox
node_startup -->|"uses settings"| node_configuration
node_router -->|"uses history"| node_history
node_main -->|"hosts lifecycle"| node_childsdk
node_childsdk -.->|"provides navigation"| node_childlink
node_main -.->|"registers modules"| node_moduleapi
node_moduleapi -->|"parses runtime"| node_runtime
node_moduleapi -->|"executes module"| node_moduleloader
node_moduleapi -->|"creates sandbox"| node_sandbox
node_main -.->|"shares data"| node_datastore
node_main -.->|"shares events"| node_events

click node_router "https://github.com/ice-lab/icestark/blob/master/packages/icestark/src/AppRouter.tsx"
click node_route "https://github.com/ice-lab/icestark/blob/master/packages/icestark/src/AppRoute.tsx"
click node_history "https://github.com/ice-lab/icestark/blob/master/packages/icestark/src/appHistory.ts"
click node_matcher "https://github.com/ice-lab/icestark/blob/master/packages/icestark/src/util/checkActive.ts"
click node_registry "https://github.com/ice-lab/icestark/blob/master/packages/icestark/src/apps.ts"
click node_startup "https://github.com/ice-lab/icestark/blob/master/packages/icestark/src/start.ts"
click node_configuration "https://github.com/ice-lab/icestark/blob/master/packages/icestark/src/util/globalConfiguration.ts"
click node_prefetch "https://github.com/ice-lab/icestark/blob/master/packages/icestark/src/util/prefetch.ts"
click node_asset "https://github.com/ice-lab/icestark/blob/master/packages/icestark/src/util/handleAssets.ts"
click node_loader "https://github.com/ice-lab/icestark/blob/master/packages/icestark/src/util/loaders.ts"
click node_lifecycle "https://github.com/ice-lab/icestark/blob/master/packages/icestark/src/util/getLifecycle.ts"
click node_sandbox "https://github.com/ice-lab/icestark/blob/master/packages/sandbox/src/index.ts"
click node_childsdk "https://github.com/ice-lab/icestark/tree/master/packages/icestark-app/src"
click node_childlink "https://github.com/ice-lab/icestark/blob/master/packages/icestark-app/src/AppLink.tsx"
click node_moduleapi "https://github.com/ice-lab/icestark/blob/master/packages/icestark-module/src/modules.tsx"
click node_moduleloader "https://github.com/ice-lab/icestark/blob/master/packages/icestark-module/src/loader.ts"
click node_runtime "https://github.com/ice-lab/icestark/blob/master/packages/icestark-module/src/runtimeHelper.ts"
click node_datastore "https://github.com/ice-lab/icestark/blob/master/packages/icestark-data/src/store.ts"
click node_events "https://github.com/ice-lab/icestark/blob/master/packages/icestark-data/src/event.ts"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_router,node_route,node_history,node_matcher,node_registry,node_startup,node_configuration,node_prefetch toneBlue
class node_asset,node_loader,node_lifecycle,node_sandbox toneAmber
class node_childsdk,node_childlink toneMint
class node_moduleapi,node_moduleloader,node_runtime,node_datastore,node_events toneRose
class node_main toneIndigo
```

## Components

### Host Runtime

- [App Router](https://github.com/ice-lab/icestark/blob/master/packages/icestark/src/AppRouter.tsx): `packages/icestark/src/AppRouter.tsx`
- [App Route](https://github.com/ice-lab/icestark/blob/master/packages/icestark/src/AppRoute.tsx): `packages/icestark/src/AppRoute.tsx`
- [App History](https://github.com/ice-lab/icestark/blob/master/packages/icestark/src/appHistory.ts): `packages/icestark/src/appHistory.ts`
- [Active Path Matcher](https://github.com/ice-lab/icestark/blob/master/packages/icestark/src/util/checkActive.ts): `packages/icestark/src/util/checkActive.ts`
- [App Registry](https://github.com/ice-lab/icestark/blob/master/packages/icestark/src/apps.ts): `packages/icestark/src/apps.ts`
- [Runtime Startup](https://github.com/ice-lab/icestark/blob/master/packages/icestark/src/start.ts): `packages/icestark/src/start.ts`
- [Global Configuration](https://github.com/ice-lab/icestark/blob/master/packages/icestark/src/util/globalConfiguration.ts): `packages/icestark/src/util/globalConfiguration.ts`
- [Asset Prefetch](https://github.com/ice-lab/icestark/blob/master/packages/icestark/src/util/prefetch.ts): `packages/icestark/src/util/prefetch.ts`

### Loading and Isolation

- [Asset Processing](https://github.com/ice-lab/icestark/blob/master/packages/icestark/src/util/handleAssets.ts): `packages/icestark/src/util/handleAssets.ts`
- [Script Loaders](https://github.com/ice-lab/icestark/blob/master/packages/icestark/src/util/loaders.ts): `packages/icestark/src/util/loaders.ts`
- [Lifecycle Resolution](https://github.com/ice-lab/icestark/blob/master/packages/icestark/src/util/getLifecycle.ts): `packages/icestark/src/util/getLifecycle.ts`
- [JavaScript Sandbox](https://github.com/ice-lab/icestark/blob/master/packages/sandbox/src/index.ts): `packages/sandbox/src/index.ts`

### Sub-app Integration

- [Sub-app Helpers](https://github.com/ice-lab/icestark/tree/master/packages/icestark-app/src): `packages/icestark-app/src`
- [Sub-app Link](https://github.com/ice-lab/icestark/blob/master/packages/icestark-app/src/AppLink.tsx): `packages/icestark-app/src/AppLink.tsx`

### Modules and Shared Data

- [Module Registry](https://github.com/ice-lab/icestark/blob/master/packages/icestark-module/src/modules.tsx): `packages/icestark-module/src/modules.tsx`
- [Module Loader](https://github.com/ice-lab/icestark/blob/master/packages/icestark-module/src/loader.ts): `packages/icestark-module/src/loader.ts`
- [Runtime Helpers](https://github.com/ice-lab/icestark/blob/master/packages/icestark-module/src/runtimeHelper.ts): `packages/icestark-module/src/runtimeHelper.ts`
- [Shared Store](https://github.com/ice-lab/icestark/blob/master/packages/icestark-data/src/store.ts): `packages/icestark-data/src/store.ts`
- [Shared Events](https://github.com/ice-lab/icestark/blob/master/packages/icestark-data/src/event.ts): `packages/icestark-data/src/event.ts`

### Other components

- **Main Application**

## Connections

- Main Application → App Router: configures (evidence: `README.md`)
- App Router → App Route: renders (evidence: `packages/icestark/src/AppRouter.tsx`)
- App Router → Runtime Startup: starts (evidence: `packages/icestark/src/AppRouter.tsx`)
- App Router → Asset Prefetch: prefetches (evidence: `packages/icestark/src/AppRouter.tsx`)
- App Route → Active Path Matcher: matches paths (evidence: `packages/icestark/src/AppRoute.tsx`)
- App Route → App Registry: registers app (evidence: `packages/icestark/src/AppRoute.tsx`)
- Main Application → App Registry: registers apps (evidence: `README.md`)
- Main Application → Runtime Startup: starts runtime (evidence: `README.md`)
- Runtime Startup → App Registry: dispatches (evidence: `packages/icestark/src/start.ts`)
- App Registry → Active Path Matcher: checks activity (evidence: `packages/icestark/src/apps.ts`)
- App Registry → Asset Processing: parses assets (evidence: `packages/icestark/src/apps.ts`)
- App Registry → Script Loaders: loads scripts (evidence: `packages/icestark/src/apps.ts`)
- App Registry → Lifecycle Resolution: resolves lifecycle (evidence: `packages/icestark/src/apps.ts`)
- App Registry → JavaScript Sandbox: creates sandbox (evidence: `packages/icestark/src/apps.ts`)
- Runtime Startup → Global Configuration: uses settings (evidence: `packages/icestark/src/start.ts`)
- App Router → App History: uses history (evidence: `packages/icestark/src/AppRouter.tsx`)
- Main Application → Sub-app Helpers: hosts lifecycle (evidence: `README.md`)
- Sub-app Helpers → Sub-app Link: provides navigation (evidence: `packages/icestark-app/src/AppLink.tsx`)
- Main Application → Module Registry: registers modules
- Module Registry → Runtime Helpers: parses runtime (evidence: `packages/icestark-module/src/modules.tsx`)
- Module Registry → Module Loader: executes module (evidence: `packages/icestark-module/src/modules.tsx`)
- Module Registry → JavaScript Sandbox: creates sandbox (evidence: `packages/icestark-module/src/modules.tsx`)
- Main Application → Shared Store: shares data
- Main Application → Shared Events: shares events
