# cuixiaorui/mini-vue architecture

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

- Interactive diagram: https://gitdiagram.com/cuixiaorui/mini-vue
- Repository: https://github.com/cuixiaorui/mini-vue

## Overview

##### Project Type and Purpose
- The project is a modular, monorepo implementation of Vue 3’s core modules aimed at learning and exploring Vue’s fundamental architecture. It is not an industrial application but a deliberately simplified version that strips out peripheral logic to focus on core concepts.
- The README highlights that its purpose is to let learners “从零到一实现一遍” (build the core logic themselves) in order to understand the inner workings of Vue 3—covering reactivity, runtime component handling, and template compilation.

##### File Structure
- There are several top-level packages under a “packages” folder:
– compiler-core: Deals with parsing templates (e.g., transforming interpolations, elements, and text nodes) and generating code (via codegen, transform, parse, etc.).
– reactivity: Implements the reactive system including reactive/ref, computed, dependency tracking, shallow/readonly mechanisms, etc.
– runtime-core: Manages the component system such as component instantiation, props/emit, component proxy, slot management, scheduler (e.g., nextTick), and instance retrieval.
– runtime-dom: Provides support for custom DOM renderers.
– runtime-test: Contains tests that validate runtime-core logic.
– shared: Exposes common utilities and type definitions (like shapeFlags) that are used across the system.
– vue: Acts as an aggregate package with examples and likely integration glue to demonstrate how these modules work together in a real application.
- Additionally, there are configuration files for pnpm (monorepo setup), Rollup, TypeScript, and Vitest, indicating use of modern build and test tooling.

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "Monorepo/PNPM Workspace"
        TemplateInput["Template Input"]:::input
        CompilerCore["Compiler-Core Module\n(parses templates & generates render functions)"]:::core
        RuntimeCore["Runtime-Core Module\n(manages component lifecycle & scheduling)"]:::core
        Reactivity["Reactivity Module\n(state tracking: reactive, ref, computed)"]:::core
        RuntimeDom["Runtime-Dom Module\n(implements custom DOM renderers)"]:::core
        Shared["Shared Module\n(common utilities & shapeFlags)"]:::support
        VuePkg["Vue Package\n(integration & demo layer)"]:::integration
        RuntimeTest["Runtime-Test Module\n(unit tests for runtime-core)"]:::test
    end

    TemplateInput -->|"parses"| CompilerCore
    CompilerCore -->|"generatesRenderFn"| RuntimeCore
    RuntimeCore -->|"tracksState"| Reactivity
    RuntimeCore -->|"renders"| RuntimeDom
    CompilerCore -->|"uses"| Shared
    RuntimeCore -->|"uses"| Shared
    VuePkg -->|"integrates"| CompilerCore
    VuePkg -->|"integrates"| RuntimeCore
    VuePkg -->|"integrates"| Reactivity
    VuePkg -->|"integrates"| RuntimeDom
    RuntimeTest -->|"tests"| RuntimeCore

    click Reactivity "https://github.com/cuixiaorui/mini-vue/tree/master/packages/reactivity"
    click CompilerCore "https://github.com/cuixiaorui/mini-vue/tree/master/packages/compiler-core"
    click RuntimeCore "https://github.com/cuixiaorui/mini-vue/tree/master/packages/runtime-core"
    click RuntimeDom "https://github.com/cuixiaorui/mini-vue/tree/master/packages/runtime-dom"
    click Shared "https://github.com/cuixiaorui/mini-vue/tree/master/packages/shared"
    click VuePkg "https://github.com/cuixiaorui/mini-vue/tree/master/packages/vue"
    click RuntimeTest "https://github.com/cuixiaorui/mini-vue/tree/master/packages/runtime-test"

    classDef core fill:#FFEDCC,stroke:#D35400,stroke-width:2px;
    classDef support fill:#D5F5E3,stroke:#27AE60,stroke-width:2px;
    classDef input fill:#D6EAF8,stroke:#3498DB,stroke-width:2px;
    classDef integration fill:#FADBD8,stroke:#C0392B,stroke-width:2px;
    classDef test fill:#F6DDCC,stroke:#B9770E,stroke-width:2px;
```
