# vuejs/vue-vapor architecture

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

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

## Overview

##### Main Components Identification

The system can be broken down into several key packages:
- Compiler Layer
- compiler-core
- compiler-dom
- compiler-sfc
- compiler-vapor (new addition specific to Vapor)
- Runtime Layer
- runtime-core
- runtime-dom
- runtime-vapor (new addition)
- runtime-shared
- Reactivity System
- reactivity package

##### Key Relationships to Highlight

- Template Compilation Flow:
- Template → compiler-vapor → Optimized Render Code → runtime-vapor → DOM

- Component Lifecycle:
- Component Definition → Compilation → Runtime Initialization → Direct DOM Updates

**┌─────────────────────────────────────────────┐**
- Vue Vapor App                   │
- ┤
- ┌─────────────┐  ┌──────────┐  ┌─────────┐ │
- SFC      │  │Template  │  │  Script │ │
- Compiler   │  │ Explorer │  │  Setup  │ │
- ┘  └──────────┘  └─────────┘ │
- ┤
- Vapor Compilation Pipeline           │
- ┌─────────────┐  ┌──────────┐  ┌─────────┐ │
- compiler-  │  │compiler- │  │compiler- │ │
- vapor    │──│   core   │──│   dom   │ │
- ┘  └──────────┘  └─────────┘ │
- ┤
- Runtime Layer                      │
- ┌─────────────┐  ┌──────────┐  ┌─────────┐ │
- runtime-   │  │ runtime- │  │   DOM   │ │
- vapor    │──│   core   │──│  APIs   │ │
- ┘  └──────────┘  └─────────┘ │
- ┤
- ┌─────────────────────────────────────────┐ │
- Reactivity System             │ │
- ┘ │
- ┘

##### Additional Notes

- Provide annotations for key optimization points
- Version compatibility notes
- Integration points with existing Vue ecosystem

Remember to maintain a balance between detail and clarity, focusing on the core architectural decisions that make Vue Vapor unique while showing how it integrates with the broader Vue ecosystem.

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph "Application Layer"
        VueVapor["Vue Vapor App"]:::app
        SFCCompiler["SFC Compiler"]:::compiler
        TemplateExplorer["Template Explorer"]:::devtool
        ScriptSetup["Script Setup"]:::compiler
    end

    subgraph "Compilation Layer"
        CompilerVapor["Compiler Vapor"]:::compiler
        CompilerCore["Compiler Core"]:::compiler
        CompilerDOM["Compiler DOM"]:::compiler
        CompilerSFC["Compiler SFC"]:::compiler
    end

    subgraph "Runtime Layer"
        RuntimeVapor["Runtime Vapor"]:::runtime
        RuntimeCore["Runtime Core"]:::runtime
        RuntimeDOM["Runtime DOM"]:::runtime
        RuntimeShared["Runtime Shared"]:::runtime
        DOMAPIs["DOM APIs"]:::runtime
    end

    subgraph "Foundation Layer"
        ReactivitySystem["Reactivity System"]:::reactivity
        SharedUtils["Shared Utilities"]:::util
    end

    %% Relationships
    VueVapor --> SFCCompiler
    VueVapor --> TemplateExplorer
    VueVapor --> ScriptSetup

    SFCCompiler --> CompilerVapor
    CompilerVapor --> CompilerCore
    CompilerCore --> CompilerDOM
    CompilerDOM --> RuntimeVapor
    CompilerSFC --> CompilerVapor

    RuntimeVapor --> RuntimeCore
    RuntimeCore --> RuntimeDOM
    RuntimeDOM --> DOMAPIs
    RuntimeShared --> RuntimeCore

    RuntimeVapor --> ReactivitySystem
    SharedUtils --> RuntimeCore
    SharedUtils --> CompilerCore

    %% Styles
    classDef app fill:#f9f,stroke:#333,stroke-width:2px
    classDef compiler fill:#69c,stroke:#333,stroke-width:2px
    classDef runtime fill:#3c3,stroke:#333,stroke-width:2px
    classDef reactivity fill:#f93,stroke:#333,stroke-width:2px
    classDef util fill:#999,stroke:#333,stroke-width:2px
    classDef devtool fill:#c6f,stroke:#333,stroke-width:2px

    %% Click Events
    click CompilerCore "https://github.com/vuejs/vue-vapor/tree/main/packages/compiler-core/"
    click CompilerDOM "https://github.com/vuejs/vue-vapor/tree/main/packages/compiler-dom/"
    click CompilerSFC "https://github.com/vuejs/vue-vapor/tree/main/packages/compiler-sfc/"
    click CompilerVapor "https://github.com/vuejs/vue-vapor/tree/main/packages/compiler-vapor/"
    click RuntimeCore "https://github.com/vuejs/vue-vapor/tree/main/packages/runtime-core/"
    click RuntimeDOM "https://github.com/vuejs/vue-vapor/tree/main/packages/runtime-dom/"
    click RuntimeVapor "https://github.com/vuejs/vue-vapor/tree/main/packages/runtime-vapor/"
    click RuntimeShared "https://github.com/vuejs/vue-vapor/tree/main/packages/runtime-shared/"
    click ReactivitySystem "https://github.com/vuejs/vue-vapor/tree/main/packages/reactivity/"
    click TemplateExplorer "https://github.com/vuejs/vue-vapor/tree/main/packages-private/template-explorer/"
    click SharedUtils "https://github.com/vuejs/vue-vapor/tree/main/packages/shared/"
    click VueVapor "https://github.com/vuejs/vue-vapor/tree/main/packages/vue-vapor/"
```
