# vuejs/vue architecture

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

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

## Overview

#### Purpose and lifecycle
This is the end-of-life Vue 2 source repository: an ES5-compatible, progressive UI framework. It produces browser runtime/compiler builds plus companion packages for Single File Component (SFC) compilation and server-side rendering (SSR). Primary public build entry points are web runtime variants under `src/platforms/web/entry-runtime.ts`, `src/platforms/web/entry-runtime-with-compiler.ts`, and `src/platforms/web/entry-compiler.ts`.

#### Build and published surfaces
The monorepo uses pnpm workspaces and custom build orchestration. `scripts/config.js` defines build targets and aliases; `scripts/build.js` generates distributable artifacts, including `dist/vue.common.js` and `dist/vue.runtime.common.js`. Published package boundaries include the core Vue package, SFC compiler at `packages/compiler-sfc/src/index.ts`, template compiler package at `packages/template-compiler/index.js`, and SSR package at `packages/server-renderer/src/index.ts`.

#### Instance and public API layer
`src/core/index.ts` assembles the framework constructor. Instance initialization, option merging, state, lifecycle, events, injection, and render behavior are layered in `src/core/instance/init.ts`, `src/core/instance/state.ts`, and `src/core/instance/lifecycle.ts`. Global extension points—components, directives, plugins, mixins, subclasses—are installed through `src/core/global-api/index.ts` and its adjacent modules. This boundary turns user component options into initialized component instances.

#### Reactivity and update scheduling
Vue 2’s observation system converts data and arrays into dependency-tracked state. `src/core/observer/index.ts` creates observers, `src/core/observer/dep.ts` manages subscriptions, and `src/core/observer/watcher.ts` evaluates render/user/computed watchers. Mutations enqueue batched work through `src/core/observer/scheduler.ts`; the next-tick machinery then coordinates asynchronous DOM updates. The optional Vue 3-compatible APIs and proxy-style reactivity live separately in `src/v3/index.ts` and `src/v3/reactivity/reactive.ts`.

#### Rendering, VNodes, and browser patching
Render functions create VNodes and components via `src/core/vdom/create-element.ts` and `src/core/vdom/create-component.ts`. The platform-neutral patch algorithm in `src/core/vdom/patch.ts` reconciles old and new trees. The web adapter supplies real DOM operations and browser modules—attributes, classes, events, DOM properties, styles, transitions—through `src/platforms/web/runtime/patch.ts`, `src/platforms/web/runtime/node-ops.ts`, and `src/platforms/web/runtime/modules/index.ts`. This is the key core-to-browser boundary.

#### Template and SFC compilation
At build time or runtime-with-compiler, templates flow through parsing, optimization, and JavaScript render-function generation: `src/compiler/parser/index.ts`, `src/compiler/optimizer.ts`, and `src/compiler/codegen/index.ts`. Web-specific directives and compiler modules extend those generic stages under `src/platforms/web/compiler/index.ts`. SFC compilation independently parses `.vue` blocks and compiles script, template, styles, scoped CSS, and CSS variables in `packages/compiler-sfc/src/parse.ts`, `packages/compiler-sfc/src/compileScript.ts`, and `packages/compiler-sfc/src/compileTemplate.ts`; loaders/bundlers consume this API externally.

#### Server rendering
SSR runs the same component/VNode model without browser DOM patching. `packages/server-renderer/src/create-renderer.ts` exposes render-to-string/stream behavior, while `packages/server-renderer/src/render.ts` traverses VNodes into HTML using SSR modules and directives. Bundle rendering isolates application bundles in `packages/server-renderer/src/bundle-renderer/create-bundle-renderer.ts`; template integration and client asset injection are handled by `packages/server-renderer/src/template-renderer/index.ts`. Webpack plugins at `packages/server-renderer/src/webpack-plugin/client.ts` and `packages/server-renderer/src/webpack-plugin/server.ts` generate manifests consumed at this SSR boundary.

Main entry points: [`scripts/build.js`](https://github.com/vuejs/vue/blob/main/scripts/build.js) (Artifact builder), [`src/core/index.ts`](https://github.com/vuejs/vue/blob/main/src/core/index.ts) (Vue constructor), [`src/core/vdom/create-element.ts`](https://github.com/vuejs/vue/blob/main/src/core/vdom/create-element.ts) (VNode creation), [`src/compiler/parser/index.ts`](https://github.com/vuejs/vue/blob/main/src/compiler/parser/index.ts) (Template compiler pipeline)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_build["Build &amp; packages"]
  node_build_config["Build targets &amp; aliases<br/>build config<br/>[config.js]"]
  node_build_orchestrator["Artifact builder<br/>build script<br/>[build.js]"]
  node_dist["Browser/CommonJS dist<br/>published artifacts<br/>[vue.common.js]"]
end

subgraph group_core["Core runtime"]
  node_core_constructor["Vue constructor<br/>core API<br/>[index.ts]"]
  node_instance["Instance initialization<br/>instance layer<br/>[init.ts]"]
  node_global_api["Global extension API<br/>extension layer<br/>[index.ts]"]
  node_observer["Observation &amp; deps<br/>reactivity core<br/>[index.ts]"]
  node_watcher["Watchers &amp; scheduler<br/>update scheduler<br/>[watcher.ts]"]
  node_vdom["VNode creation<br/>virtual DOM<br/>[create-element.ts]"]
  node_patch["Platform-neutral patch<br/>reconciler<br/>[patch.ts]"]
  node_v3_api["Vue 3-compatible APIs<br/>optional reactivity API<br/>[index.ts]"]
end

subgraph group_web["Web platform"]
  node_web_runtime_entry["Web runtime entry<br/>public entry<br/>[entry-runtime.ts]"]
  node_web_compiler_entry["Web compiler entry<br/>public entry"]
  node_web_patch["DOM patch adapter<br/>web runtime adapter<br/>[patch.ts]"]
end

subgraph group_compile["Compilation"]
  node_template_compiler["Template compiler pipeline<br/>[index.ts]"]
  node_web_compiler["Web compiler extensions<br/>platform compiler<br/>[index.ts]"]
  node_sfc_compiler["SFC compiler package<br/>published package<br/>[index.ts]"]
  node_template_package["Template compiler package<br/>published package<br/>[index.js]"]
end

subgraph group_ssr["Server rendering"]
  node_ssr_renderer["SSR renderer<br/>SSR API<br/>[create-renderer.ts]"]
  node_ssr_render["VNode-to-HTML traversal<br/>SSR renderer core<br/>[render.ts]"]
  node_bundle_renderer["SSR bundle renderer<br/>SSR bundle API"]
  node_template_renderer["SSR template integration<br/>SSR integration<br/>[index.ts]"]
end

node_build_config -->|"defines targets"| node_build_orchestrator
node_build_orchestrator -->|"generates"| node_dist
node_web_runtime_entry -->|"loads"| node_core_constructor
node_web_compiler_entry -->|"loads"| node_core_constructor
node_web_compiler_entry -->|"includes"| node_template_compiler
node_core_constructor -->|"installs instance API"| node_instance
node_core_constructor -->|"installs global API"| node_global_api
node_instance -->|"observes state"| node_observer
node_observer -->|"notifies dependencies"| node_watcher
node_watcher -->|"drives re-render"| node_vdom
node_vdom -->|"produces trees for"| node_patch
node_patch -->|"uses platform adapter"| node_web_patch
node_v3_api -.->|"separate from"| node_observer
node_template_compiler -->|"extended by"| node_web_compiler
node_web_compiler -->|"generates render functions"| node_vdom
node_sfc_compiler -->|"compiles SFC templates through"| node_template_compiler
node_template_package -->|"publishes"| node_template_compiler
node_ssr_renderer -->|"delegates rendering"| node_ssr_render
node_ssr_render -->|"consumes shared VNodes"| node_vdom
node_bundle_renderer -->|"renders app bundles with"| node_ssr_renderer
node_template_renderer -->|"integrates rendered bundles"| node_bundle_renderer
node_build_orchestrator -->|"bundles"| node_web_runtime_entry
node_build_orchestrator -->|"bundles"| node_web_compiler_entry

click node_build_config "https://github.com/vuejs/vue/blob/main/scripts/config.js"
click node_build_orchestrator "https://github.com/vuejs/vue/blob/main/scripts/build.js"
click node_dist "https://github.com/vuejs/vue/blob/main/dist/vue.common.js"
click node_core_constructor "https://github.com/vuejs/vue/blob/main/src/core/index.ts"
click node_instance "https://github.com/vuejs/vue/blob/main/src/core/instance/init.ts"
click node_global_api "https://github.com/vuejs/vue/blob/main/src/core/global-api/index.ts"
click node_observer "https://github.com/vuejs/vue/blob/main/src/core/observer/index.ts"
click node_watcher "https://github.com/vuejs/vue/blob/main/src/core/observer/watcher.ts"
click node_vdom "https://github.com/vuejs/vue/blob/main/src/core/vdom/create-element.ts"
click node_patch "https://github.com/vuejs/vue/blob/main/src/core/vdom/patch.ts"
click node_v3_api "https://github.com/vuejs/vue/blob/main/src/v3/index.ts"
click node_web_runtime_entry "https://github.com/vuejs/vue/blob/main/src/platforms/web/entry-runtime.ts"
click node_web_compiler_entry "https://github.com/vuejs/vue/blob/main/src/platforms/web/entry-runtime-with-compiler.ts"
click node_web_patch "https://github.com/vuejs/vue/blob/main/src/platforms/web/runtime/patch.ts"
click node_template_compiler "https://github.com/vuejs/vue/blob/main/src/compiler/parser/index.ts"
click node_web_compiler "https://github.com/vuejs/vue/blob/main/src/platforms/web/compiler/index.ts"
click node_sfc_compiler "https://github.com/vuejs/vue/blob/main/packages/compiler-sfc/src/index.ts"
click node_template_package "https://github.com/vuejs/vue/blob/main/packages/template-compiler/index.js"
click node_ssr_renderer "https://github.com/vuejs/vue/blob/main/packages/server-renderer/src/create-renderer.ts"
click node_ssr_render "https://github.com/vuejs/vue/blob/main/packages/server-renderer/src/render.ts"
click node_bundle_renderer "https://github.com/vuejs/vue/blob/main/packages/server-renderer/src/bundle-renderer/create-bundle-renderer.ts"
click node_template_renderer "https://github.com/vuejs/vue/blob/main/packages/server-renderer/src/template-renderer/index.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_build_config,node_build_orchestrator,node_dist toneBlue
class node_core_constructor,node_instance,node_global_api,node_observer,node_watcher,node_vdom,node_patch,node_v3_api toneAmber
class node_web_runtime_entry,node_web_compiler_entry,node_web_patch toneMint
class node_template_compiler,node_web_compiler,node_sfc_compiler,node_template_package toneRose
class node_ssr_renderer,node_ssr_render,node_bundle_renderer,node_template_renderer toneIndigo
```

## Components

### Build & packages

- [Build targets & aliases](https://github.com/vuejs/vue/blob/main/scripts/config.js): build config · `scripts/config.js`
- [Artifact builder](https://github.com/vuejs/vue/blob/main/scripts/build.js): build script · Generates distributable Vue artifacts. · `scripts/build.js`
- [Browser/CommonJS dist](https://github.com/vuejs/vue/blob/main/dist/vue.common.js): published artifacts · Includes full and runtime-only common builds. · `dist/vue.common.js`

### Core runtime

- [Vue constructor](https://github.com/vuejs/vue/blob/main/src/core/index.ts): core API · Assembles the framework constructor and public instance API. · `src/core/index.ts`
- [Instance initialization](https://github.com/vuejs/vue/blob/main/src/core/instance/init.ts): instance layer · Initializes options, state, lifecycle, events, and rendering. · `src/core/instance/init.ts`
- [Global extension API](https://github.com/vuejs/vue/blob/main/src/core/global-api/index.ts): extension layer · Installs components, directives, plugins, mixins, and subclasses. · `src/core/global-api/index.ts`
- [Observation & deps](https://github.com/vuejs/vue/blob/main/src/core/observer/index.ts): reactivity core · Observes data and tracks dependency subscriptions. · `src/core/observer/index.ts`
- [Watchers & scheduler](https://github.com/vuejs/vue/blob/main/src/core/observer/watcher.ts): update scheduler · Evaluates watchers and batches asynchronous updates. · `src/core/observer/watcher.ts`
- [VNode creation](https://github.com/vuejs/vue/blob/main/src/core/vdom/create-element.ts): virtual DOM · Creates VNodes and component VNodes for renders. · `src/core/vdom/create-element.ts`
- [Platform-neutral patch](https://github.com/vuejs/vue/blob/main/src/core/vdom/patch.ts): reconciler · Reconciles old and new VNode trees. · `src/core/vdom/patch.ts`
- [Vue 3-compatible APIs](https://github.com/vuejs/vue/blob/main/src/v3/index.ts): optional reactivity API · Separate proxy-style reactivity and compatibility APIs. · `src/v3/index.ts`

### Web platform

- [Web runtime entry](https://github.com/vuejs/vue/blob/main/src/platforms/web/entry-runtime.ts): public entry · Runtime-only browser build entry. · `src/platforms/web/entry-runtime.ts`
- [Web compiler entry](https://github.com/vuejs/vue/blob/main/src/platforms/web/entry-runtime-with-compiler.ts): public entry · Runtime-with-compiler browser build entry. · `src/platforms/web/entry-runtime-with-compiler.ts`
- [DOM patch adapter](https://github.com/vuejs/vue/blob/main/src/platforms/web/runtime/patch.ts): web runtime adapter · Connects core patching to DOM operations and browser modules. · `src/platforms/web/runtime/patch.ts`

### Compilation

- [Template compiler pipeline](https://github.com/vuejs/vue/blob/main/src/compiler/parser/index.ts): compiler · Parses, optimizes, and generates render functions. · `src/compiler/parser/index.ts`
- [Web compiler extensions](https://github.com/vuejs/vue/blob/main/src/platforms/web/compiler/index.ts): platform compiler · Adds web directives and compiler modules. · `src/platforms/web/compiler/index.ts`
- [SFC compiler package](https://github.com/vuejs/vue/blob/main/packages/compiler-sfc/src/index.ts): published package · Parses and compiles .vue script, template, styles, and scoped CSS. · `packages/compiler-sfc/src/index.ts`
- [Template compiler package](https://github.com/vuejs/vue/blob/main/packages/template-compiler/index.js): published package · `packages/template-compiler/index.js`

### Server rendering

- [SSR renderer](https://github.com/vuejs/vue/blob/main/packages/server-renderer/src/create-renderer.ts): SSR API · Renders the shared component and VNode model to strings or streams. · `packages/server-renderer/src/create-renderer.ts`
- [VNode-to-HTML traversal](https://github.com/vuejs/vue/blob/main/packages/server-renderer/src/render.ts): SSR renderer core · Traverses VNodes with SSR modules and directives. · `packages/server-renderer/src/render.ts`
- [SSR bundle renderer](https://github.com/vuejs/vue/blob/main/packages/server-renderer/src/bundle-renderer/create-bundle-renderer.ts): SSR bundle API · Runs application bundles in an isolated rendering context. · `packages/server-renderer/src/bundle-renderer/create-bundle-renderer.ts`
- [SSR template integration](https://github.com/vuejs/vue/blob/main/packages/server-renderer/src/template-renderer/index.ts): SSR integration · Injects rendered content and client assets into templates. · `packages/server-renderer/src/template-renderer/index.ts`

## Connections

- Build targets & aliases → Artifact builder: defines targets
- Artifact builder → Browser/CommonJS dist: generates
- Web runtime entry → Vue constructor: loads
- Web compiler entry → Vue constructor: loads
- Web compiler entry → Template compiler pipeline: includes
- Vue constructor → Instance initialization: installs instance API
- Vue constructor → Global extension API: installs global API
- Instance initialization → Observation & deps: observes state
- Observation & deps → Watchers & scheduler: notifies dependencies
- Watchers & scheduler → VNode creation: drives re-render
- VNode creation → Platform-neutral patch: produces trees for
- Platform-neutral patch → DOM patch adapter: uses platform adapter
- Vue 3-compatible APIs → Observation & deps: separate from
- Template compiler pipeline → Web compiler extensions: extended by
- Web compiler extensions → VNode creation: generates render functions
- SFC compiler package → Template compiler pipeline: compiles SFC templates through
- Template compiler package → Template compiler pipeline: publishes
- SSR renderer → VNode-to-HTML traversal: delegates rendering
- VNode-to-HTML traversal → VNode creation: consumes shared VNodes
- SSR bundle renderer → SSR renderer: renders app bundles with
- SSR template integration → SSR bundle renderer: integrates rendered bundles
- Artifact builder → Web runtime entry: bundles
- Artifact builder → Web compiler entry: bundles
