# rancher/dashboard architecture

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

- Interactive diagram: https://gitdiagram.com/rancher/dashboard
- Repository: https://github.com/rancher/dashboard

## Overview

##### Project Type & Purpose
- This is a monorepo for a full-stack, Vue/Nuxt-based single-page application (“shell”) that powers the Rancher Dashboard UI.
- It includes an extension/plugin mechanism (pkg/*), a shared component library (pkg/rancher-components), E2E tests (cypress/), documentation site (docusaurus/), storybook for components, and CI/CD scripts (.github/, scripts/).

##### File-Structure Analysis
- Top-level directories:
- shell/ – the main Vue application: components/, pages/, store/, plugins/, utils/, models/, router/
- pkg/ – extension packages (AKS, EKS, GKE, imported, kubectl-explain, rancher-components, rancher-prime, etc.) each exporting Vue components and provisioners
- cypress/ – end-to-end tests and fixtures, page-object models, commands, CI scripts
- docusaurus/ – internal developer docs site
- storybook/ – interactive component explorer
- scripts/ – build, packaging, publishing, versioning, test orchestration
- .github/ – GitHub Actions workflows for linting, tests, build & publish
- Build/config files: vue.config.js, tsconfig.json, babel.config.js, jest.config.js

##### Core README Insights
- Rancher Dashboard is a UI for Kubernetes cluster management with a plugin API for extensions.
- Internal docs live under docusaurus/; extension docs are external.

a. Main Components
1. Developer/CI Layer
– Developer Workstation: clone, install, run scripts
– CI/CD Pipelines (GitHub Actions, Jenkins via cypress/jenkins/)
2. Build & Package Layer
– scripts/ & package.json scripts produce:
- shell bundle (Web assets)
- npm packages for pkg/* modules
- docs site (docusaurus)
- storybook build
3. Runtime UI Application (“shell”)
– Vue/Nuxt SPA
– Vuex store (shell/store/)
– Router & navigation guards (shell/config/router/)
– Plugins loader (shell/core/, dynamic imports via shell/pkg/)
– Shared component library (pkg/rancher-components)
– Extension packages (pkg/*) dynamically loaded at runtime
4. External Services
– Rancher API Server (REST + WebSocket via steve plugin)
– Cloud-provider APIs (AWS, Azure, GCP) used by extension provisioners
5. Testing & Quality
– Unit tests (Jest in each pkg and shell/__tests__)
– E2E tests (cypress/) running in CI
– Storybook (component isolation + snapshot tests)
6. Documentation
– Docusaurus site (docusaurus/) for internal developer docs
– README, API specs under docs/

b. Relationships & Data Flows
- Developer → triggers CI pipelines → runs lint, unit, E2E, storybook, docs build → publishes npm packages & docs
- Browser loads shell bundle → initializes plugins via shell/core/plugins-loader → merges core modules + each pkg/* extension
- shell app ↔ Vuex store (synchronous state management)
- shell app → Rancher API (HTTP REST) for CRUD on k8s resources
- shell app → WebSocket to receive live updates via steve plugin
- shell app → dynamic imports pkg/* to extend UI (new pages, components, nav items)
- cypress runner → controls browser → executes page-object flows → validates UI against mock or real API

c. Architectural Patterns & Principles
- Modular plugin architecture: core + extensions loaded at runtime
- MVVM via Vue.js (views in shell/pages + components, state in Vuex store)
- Layered testing: unit, E2E, integration in storybook
- Monorepo with per-package versioning and shared dev scripts

d. Key Technologies
- Vue.js + Nuxt (shell)
- Vuex for state
- Typescript/Javascript, Babel, Webpack
- Jest for unit tests
- Cypress for E2E
- Docusaurus for docs
- Storybook for UI components
- GitHub Actions & Jenkins for CI/CD

## Diagram (Mermaid)

```mermaid
graph TB
    %% Developer & CI
    subgraph "Developer & CI Environment"
        direction TB
        Dev("Developer Workstation"):::user
        CI["GitHub Actions"]:::ci
        Scripts["Scripts"]:::ci
    end
    click CI "https://github.com/rancher/dashboard/tree/master/.github/"
    click Scripts "https://github.com/rancher/dashboard/tree/master/scripts/"

    %% Build & Config
    subgraph "Build & Package Layer"
        direction TB
        Configs["Build Configs"]:::ci
    end
    Configs -->|"uses"| Scripts
    click Configs "https://github.com/rancher/dashboard/blob/master/vue.config.js, tsconfig.json, babel.config.js, jest.config.js, package.json"

    %% Monorepo Modules
    subgraph "Monorepo"
        direction TB

        subgraph "Core App (shell)" 
            direction TB
            ShellApp["Vue/Nuxt Shell"]:::core
            Pages["shell/pages/"]:::core
            Components["shell/components/"]:::core
            Store["shell/store/"]:::core
            Router["shell/config/router/"]:::core
            PluginLoader["shell/core/plugins-loader.js"]:::core
            PkgLoader["shell/pkg/ (dynamic pkg loader)"]:::core
        end
        click ShellApp "https://github.com/rancher/dashboard/tree/master/shell/"
        click Pages "https://github.com/rancher/dashboard/tree/master/shell/pages/"
        click Components "https://github.com/rancher/dashboard/tree/master/shell/components/"
        click Store "https://github.com/rancher/dashboard/tree/master/shell/store/"
        click Router "https://github.com/rancher/dashboard/tree/master/shell/config/router/"
        click PluginLoader "https://github.com/rancher/dashboard/blob/master/shell/core/plugins-loader.js"
        click PkgLoader "https://github.com/rancher/dashboard/tree/master/shell/pkg/"

        subgraph "Shared Component Library"
            direction TB
            RancherComponents["pkg/rancher-components"]:::shared
        end
        click RancherComponents "https://github.com/rancher/dashboard/tree/master/pkg/rancher-components/"

        subgraph "Extensions (pkg/*)"
            direction TB
            AKS["pkg/aks/"]:::ext
            EKS["pkg/eks/"]:::ext
            GKE["pkg/gke/"]:::ext
            Imported["pkg/imported/"]:::ext
            KubectlExplain["pkg/kubectl-explain/"]:::ext
            HarvMgr["pkg/harvester-manager/"]:::ext
            RancherPrime["pkg/rancher-prime/"]:::ext
        end
        click AKS "https://github.com/rancher/dashboard/tree/master/pkg/aks/"
        click EKS "https://github.com/rancher/dashboard/tree/master/pkg/eks/"
        click GKE "https://github.com/rancher/dashboard/tree/master/pkg/gke/"
        click Imported "https://github.com/rancher/dashboard/tree/master/pkg/imported/"
        click KubectlExplain "https://github.com/rancher/dashboard/tree/master/pkg/kubectl-explain/"
        click HarvMgr "https://github.com/rancher/dashboard/tree/master/pkg/harvester-manager/"
        click RancherPrime "https://github.com/rancher/dashboard/tree/master/pkg/rancher-prime/"

        subgraph "Testing & Quality"
            direction TB
            UnitTests["Jest Unit Tests"]:::test
            E2ETests["Cypress E2E Tests"]:::test
            Storybook["Storybook"]:::test
        end
        click UnitTests "https://github.com/rancher/dashboard/tree/master/__tests__/"
        click E2ETests "https://github.com/rancher/dashboard/tree/master/cypress/"
        click Storybook "https://github.com/rancher/dashboard/tree/master/storybook/"

        subgraph "Documentation"
            direction TB
            Docusaurus["Docusaurus Site"]:::docs
            InternalDocs["Internal Docs"]:::docs
        end
        click Docusaurus "https://github.com/rancher/dashboard/tree/master/docusaurus/"
        click InternalDocs "https://github.com/rancher/dashboard/tree/master/docs/"
    end

    %% Runtime Environment
    subgraph "Runtime Environment"
        direction TB
        Browser["Browser"]:::user
        APIServer["Rancher API Server"]:::external
        CloudAPIs["Cloud Provider APIs"]:::external
    end

    %% Flows
    Dev -->|clone/install/run| Scripts
    Dev -->|trigger| CI
    CI -->|run| UnitTests
    CI -->|run| E2ETests
    CI -->|run| Storybook
    CI -->|build docs| Docusaurus
    CI -->|publish| RancherComponents

    Browser -->|load shell bundle| ShellApp
    ShellApp -->|render pages| Pages
    ShellApp -->|use components| Components
    ShellApp -->|state| Store
    ShellApp -->|navigate| Router
    ShellApp -->|load plugins| PluginLoader
    PluginLoader -->|dynamic import| PkgLoader
    PkgLoader -->|includes| AKS
    PkgLoader -->|includes| EKS
    PkgLoader -->|includes| GKE
    PkgLoader -->|includes| Imported
    PkgLoader -->|includes| KubectlExplain
    PkgLoader -->|includes| HarvMgr
    PkgLoader -->|includes| RancherPrime
    ShellApp -->|uses| RancherComponents

    ShellApp -->|REST CRUD| APIServer
    ShellApp -->|WebSocket| APIServer
    AKS -->|provision| CloudAPIs
    EKS -->|provision| CloudAPIs
    GKE -->|provision| CloudAPIs

    E2ETests -->|control| Browser

    %% Styles
    classDef core fill:#D0E8FF,stroke:#004A99
    classDef ext fill:#DFFFE0,stroke:#339900
    classDef shared fill:#E0F7F1,stroke:#00796B
    classDef test fill:#FFF3E0,stroke:#E65100
    classDef docs fill:#F5F5F5,stroke:#9E9E9E
    classDef ci fill:#E1BEE7,stroke:#6A1B9A
    classDef user fill:#E8EAF6,stroke:#3949AB
    classDef external fill:#FFFFFF,stroke:#424242,stroke-dasharray: 5 5
```
