# misterxiaotan/vue3-lesson architecture

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

- Interactive diagram: https://gitdiagram.com/misterxiaotan/vue3-lesson
- Repository: https://github.com/misterxiaotan/vue3-lesson

## Overview

##### Project type and purpose
- This is a monorepo library/tooling project that incrementally re-implements Vue 3.4’s reactivity system.
- Its focus is on core Vue features (reactive, ref, watch, watchEffect) in a monorepo structure, bundled via esbuild for in-browser demos.

##### File structure
- Top-level:
- pnpm-workspace.yaml & pnpm-lock.yaml → pnpm monorepo setup
- package.json & .npmrc → root dependencies/config
- tsconfig.json → shared TS settings
- scripts/dev.js → development server / build script using esbuild
- packages/
- reactivity/
– src/… (baseHandler.ts, effect.ts, reactive.ts, ref.ts, track.ts, notify.ts) → core reactive engine
– dist/… (built html, js, maps) → output artifacts
– package.json → declares the reactivity package
- shared/
– src/index.ts → utility code shared across packages
– package.json
- node_modules/ → installed dependencies for workspace

##### README
- Describes project goal (incrementally implement Vue 3.4 features)
- Lists v0.1.0 scope: reactive, ref, watch, watchEffect
- Startup: `pnpm dev` → runs scripts/dev.js (esbuild with HMR) → outputs to each package’s dist → demo HTML

##### Main components
a. Development & build layer
- scripts/dev.js
- esbuild (watch + HMR)
b. Monorepo workspace
- packages/shared (utilities)
- packages/reactivity (core reactivity engine)
c. Build output
- dist/ (per-package demo HTML + bundled JS)
d. Runtime (browser)
- Demo HTML loads bundled JS → user invokes reactive APIs
e. External tools
- pnpm (workspace management)
- TypeScript compiler (via tsconfig)

##### Relationships & data flow
- File change → scripts/dev.js → esbuild rebuild → updates dist/reactivity/reactivity.js → browser HMR reload
- At runtime: user code calls reactive()/ref() → Proxy handlers (baseHandler) → track()/notify() → effect execution
- shared module exports helpers imported by reactivity

##### Architectural patterns & principles
- Monorepo modularization (pnpm workspaces)
- Package-per-feature (reactivity, shared, future packages)
- Layered build pipeline (TS → esbuild → dist)
- Reactive pattern: observer-subscriber via track/notify

##### Technologies & frameworks
- TypeScript
- esbuild (bundler + HMR)
- pnpm (monorepo)
- Native ES Proxy for reactivity

##### Diagramming recommendations
- Use clear labels for each component (e.g., “Reactive Engine”, “Shared Utils”, “Dev Server / esbuild”)
- File change → Dev Server → Bundler → Dist artifacts → Browser
- runtime calls: Consumer Code → reactive() → Proxy → track/notify → effect callbacks
- Blue for tooling (pnpm, esbuild, scripts)
- Green for packages/modules (shared, reactivity)
- Orange for runtime/browser

## Diagram (Mermaid)

```mermaid
flowchart TD
  subgraph "Monorepo Root"
    subgraph "Configs & Tools"
      PNPM["pnpm-workspace.yaml"]:::tooling
      LOCK["pnpm-lock.yaml"]:::tooling
      PKGROOT["package.json / .npmrc"]:::tooling
      TSC["tsconfig.json"]:::tooling
      README["readme.md"]:::docs
    end

    subgraph "Development & Build Layer"
      DEV["scripts/dev.js"]:::tooling
      ESB["esbuild (watch + HMR)"]:::tooling
    end

    subgraph "Packages"
      subgraph "shared (Utilities)"
        SHARED_IDX["src/index.ts"]:::module
        SHARED_PKG["package.json"]:::module
      end

      subgraph "reactivity (Core Engine)"
        BASE["baseHandler.ts"]:::module
        EFFECT["effect.ts"]:::module
        REACTIVE["reactive.ts"]:::module
        REF["ref.ts"]:::module
        TRACK["track.ts"]:::module
        NOTIFY["notify.ts"]:::module
        IDX_R["src/index.ts"]:::module
        REACT_PKG["package.json"]:::module

        subgraph "Dist Artifacts"
          HTML["index.html"]:::output
          JS["reactivity.js"]:::output
          MAP["reactivity.js.map"]:::output
        end
      end
    end
  end

  subgraph "Browser Runtime"
    BROWSER["Demo HTML + Bundled JS"]:::runtime
  end

  %% Relationships
  PNPM --> DEV
  LOCK --> DEV
  PKGROOT --> DEV
  TSC --> DEV
  DEV --> ESB
  ESB --> HTML
  ESB --> JS
  ESB --> MAP
  HTML --> BROWSER
  JS --> BROWSER

  SHARED_IDX --> BASE
  SHARED_IDX --> EFFECT
  SHARED_IDX --> REACTIVE
  IDX_R --> BASE
  IDX_R --> EFFECT
  IDX_R --> TRACK
  IDX_R --> NOTIFY
  IDX_R --> REF

  BROWSER -->|"calls reactive()"| REACTIVE
  BROWSER -->|"calls ref()"| REF
  REACTIVE -->|"Proxy traps"| BASE
  BASE -->|"invokes track()"| TRACK
  BASE -->|"invokes notify()"| NOTIFY
  NOTIFY -->|"triggers"| EFFECT

  %% Click Events
  click DEV "https://github.com/misterxiaotan/vue3-lesson/blob/main/scripts/dev.js"
  click TSC "https://github.com/misterxiaotan/vue3-lesson/blob/main/tsconfig.json"
  click SHARED_IDX "https://github.com/misterxiaotan/vue3-lesson/blob/main/packages/shared/src/index.ts"
  click SHARED_PKG "https://github.com/misterxiaotan/vue3-lesson/blob/main/packages/shared/package.json"
  click BASE "https://github.com/misterxiaotan/vue3-lesson/blob/main/packages/reactivity/src/baseHandler.ts"
  click EFFECT "https://github.com/misterxiaotan/vue3-lesson/blob/main/packages/reactivity/src/effect.ts"
  click REACTIVE "https://github.com/misterxiaotan/vue3-lesson/blob/main/packages/reactivity/src/reactive.ts"
  click REF "https://github.com/misterxiaotan/vue3-lesson/blob/main/packages/reactivity/src/ref.ts"
  click TRACK "https://github.com/misterxiaotan/vue3-lesson/blob/main/packages/reactivity/src/track.ts"
  click NOTIFY "https://github.com/misterxiaotan/vue3-lesson/blob/main/packages/reactivity/src/notify.ts"
  click IDX_R "https://github.com/misterxiaotan/vue3-lesson/blob/main/packages/reactivity/src/index.ts"
  click REACT_PKG "https://github.com/misterxiaotan/vue3-lesson/blob/main/packages/reactivity/package.json"
  click HTML "https://github.com/misterxiaotan/vue3-lesson/blob/main/packages/reactivity/dist/index.html"
  click JS "https://github.com/misterxiaotan/vue3-lesson/blob/main/packages/reactivity/dist/reactivity.js"
  click MAP "https://github.com/misterxiaotan/vue3-lesson/blob/main/packages/reactivity/dist/reactivity.js.map"
  click PNPM "https://github.com/misterxiaotan/vue3-lesson/blob/main/pnpm-workspace.yaml"
  click LOCK "https://github.com/misterxiaotan/vue3-lesson/blob/main/pnpm-lock.yaml"
  click PKGROOT "https://github.com/misterxiaotan/vue3-lesson/blob/main/package.json"
  click README "https://github.com/misterxiaotan/vue3-lesson/blob/main/readme.md"

  %% Styles
  classDef tooling fill:#bbdefb,stroke:#0d47a1,color:#0d47a1
  classDef module fill:#c8e6c9,stroke:#1b5e20,color:#1b5e20
  classDef output fill:#eeeeee,stroke:#424242,color:#424242
  classDef runtime fill:#ffe0b2,stroke:#e65100,color:#e65100
  classDef docs fill:#f5f5f5,stroke:#9e9e9e,color:#616161
```
