# intlify/vue-i18n architecture

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

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

## Overview

##### Project Type and Purpose
- This is an open-source, monorepo library for internationalization in Vue 3 (Vue I18n v11).
- It publishes multiple npm packages (core, runtime, compiler, plugins, utilities) and provides documentation, examples, and CI/CD automation.

##### High-Level Architecture Components
a. Monorepo Root
- Configuration (tsconfig.json, rollup.config.mjs, pnpm-workspace.yaml)
- Build & Release scripts (scripts/*)
- CI/CD workflows (​.github/workflows/*.yml)
b. Core Libraries Layer
- @intlify/core-base — low-level runtime, AST, formatting, fallback logic
- @intlify/core — higher-level runtime wrappers
- @intlify/shared — utilities and common code
c. Compiler Layer
- @intlify/message-compiler — parser, tokenizer, transformer for message compilation into render functions or AST
d. Vue-Integration Layer
- vue-i18n-core — Vue 3 Composition API plugin core (components, composer, symbols)
- vue-i18n — user-facing package that wraps vue-i18n-core with plugin installer
- petite-vue-i18n — lightweight variant for smaller bundles
- devtools-types — type definitions for Vue DevTools integration
e. Tools and Utilities
- format-explorer — a demo SPA to interactively explore formatting options
- size-check packages — tools to measure bundle sizes
f. Documentation & Examples
- docs/ — VitePress site with guides, API reference, and Markdown assets
- examples/ — dozens of self-contained Vue apps demonstrating various use cases (SSR, lazy loading, TSX, etc.)

##### Relationships & Data Flows
- The build pipeline (scripts + Rollup) uses message-compiler to precompile messages in core-base and vue-i18n-core.
- Core-base → core → vue-i18n-core → vue-i18n (layered dependency chain).
- petite variant depends on core-base directly and wraps a subset of vue-i18n-core functionality.
- format-explorer and size-check projects consume the published packages.
- CI/CD workflows run lint, build, test (Vitest + e2e), then publish packages to npm.
- docs site consumes API extractor JSON outputs from each package to generate reference pages.

##### Architectural Patterns & Principles
- Monorepo managed by pnpm workspace for cross-package linking and versioning.
- Layered decomposition: parsing/compiling, runtime core, framework integration, tooling.
- Shared code lives in packages/shared to avoid duplication.
- Extensive use of build-time code generation and message compilation for runtime performance.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Monorepo Root
    subgraph "Monorepo Root"
        direction TB
        RepoConfig["pnpm-workspace.yaml<br/>rollup.config.mjs"]:::root
        CIWorkflows["GitHub Workflows"]:::external
        Scripts["Build & Release Scripts"]:::root
    end

    %% Build System
    subgraph "Build System" 
        direction TB
        Rollup["Rollup Config"]:::build
        BuildScripts["scripts/*.ts & sh"]:::build
    end

    %% Compiler Layer
    subgraph "Compiler (@intlify/message-compiler)" 
        direction TB
        CompilerCore["compiler.ts"]:::compiler
        Parser["parser.ts"]:::compiler
        Transformer["transformer.ts"]:::compiler
    end

    %% Core Libraries Layer
    subgraph "Core Libraries" 
        direction TB
        CoreBase["@intlify/core-base"]:::core
        Core["@intlify/core"]:::core
        Shared["@intlify/shared"]:::core
    end

    %% Vue-Integration Layer
    subgraph "Vue Integration Layer"
        direction TB
        VueCore["vue-i18n-core"]:::vue
        VueI18n["vue-i18n"]:::vue
        Petite["petite-vue-i18n"]:::vue
        Devtools["devtools-types"]:::vue
    end

    %% Tools and Utilities
    subgraph "Tools & Utilities"
        direction TB
        FormatExplorer["format-explorer"]:::tools
        SizeCheckCore["size-check-core"]:::tools
        SizeCheckVue["size-check-vue-i18n"]:::tools
        SizeCheckPetite["size-check-petite-vue-i18n"]:::tools
    end

    %% Documentation & Examples
    subgraph "Docs & Examples"
        direction TB
        Docs["docs (VitePress Site)"]:::docs
        Examples["examples/*"]:::docs
    end

    %% External Services
    NPM["npm Registry"]:::external
    GitHub["GitHub"]:::external

    %% Relationships
    RepoConfig -->|manages workspace| CoreBase
    RepoConfig -->|manages workspace| Core
    RepoConfig -->|manages workspace| Shared
    CIWorkflows -->|triggers| Rollup
    CIWorkflows -->|runs| BuildScripts
    BuildScripts -->|uses| Rollup
    Rollup -->|precompiles via| CompilerCore
    Rollup -->|precompiles via| Parser
    Rollup -->|precompiles via| Transformer

    CoreBase -->|dependency| Shared
    Core -->|depends on| CoreBase
    VueCore -->|depends on| Core
    VueI18n -->|wraps| VueCore
    Petite -->|depends on| CoreBase
    Petite -->|wraps subset of| VueCore

    FormatExplorer -->|consumes| CoreBase
    FormatExplorer -->|consumes| VueI18n
    SizeCheckCore -->|measures| Core
    SizeCheckVue -->|measures| VueI18n
    SizeCheckPetite -->|measures| Petite

    Docs -->|consumes API JSON| CoreBase
    Docs -->|consumes API JSON| Core
    Docs -->|consumes API JSON| VueCore

    Examples -->|demo| VueI18n
    Examples -->|demo| VueCore
    Examples -->|demo| Core

    CIWorkflows -->|publishes| NPM
    GitHub -->|hosts| CIWorkflows

    %% Click Events
    click RepoConfig "https://github.com/intlify/vue-i18n/blob/master/.github/workflows/ci.yml"
    click RepoConfig "https://github.com/intlify/vue-i18n/blob/master/.github/workflows/release.yml"
    click RepoConfig "https://github.com/intlify/vue-i18n/blob/master/.github/workflows/nightly-release.yml"
    click RepoConfig "https://github.com/intlify/vue-i18n/blob/master/pnpm-workspace.yaml"
    click RepoConfig "https://github.com/intlify/vue-i18n/blob/master/rollup.config.mjs"
    click Scripts "https://github.com/intlify/vue-i18n/blob/master/scripts/build.ts"
    click Scripts "https://github.com/intlify/vue-i18n/blob/master/scripts/rolldown.ts"
    click Scripts "https://github.com/intlify/vue-i18n/blob/master/scripts/release.sh"

    click CompilerCore "https://github.com/intlify/vue-i18n/blob/master/packages/message-compiler/src/compiler.ts"
    click Parser "https://github.com/intlify/vue-i18n/blob/master/packages/message-compiler/src/parser.ts"
    click Transformer "https://github.com/intlify/vue-i18n/blob/master/packages/message-compiler/src/transformer.ts"

    click CoreBase "https://github.com/intlify/vue-i18n/tree/master/packages/core-base/src/"
    click CoreBase "https://github.com/intlify/vue-i18n/blob/master/packages/core-base/package.json"
    click Core "https://github.com/intlify/vue-i18n/tree/master/packages/core/src/"
    click Core "https://github.com/intlify/vue-i18n/blob/master/packages/core/package.json"
    click Shared "https://github.com/intlify/vue-i18n/tree/master/packages/shared/src/"
    click Shared "https://github.com/intlify/vue-i18n/blob/master/packages/shared/package.json"

    click VueCore "https://github.com/intlify/vue-i18n/tree/master/packages/vue-i18n-core/src/"
    click VueCore "https://github.com/intlify/vue-i18n/blob/master/packages/vue-i18n-core/package.json"
    click VueI18n "https://github.com/intlify/vue-i18n/tree/master/packages/vue-i18n/src/"
    click VueI18n "https://github.com/intlify/vue-i18n/blob/master/packages/vue-i18n/package.json"
    click Petite "https://github.com/intlify/vue-i18n/tree/master/packages/petite-vue-i18n/src/"
    click Petite "https://github.com/intlify/vue-i18n/blob/master/packages/petite-vue-i18n/package.json"
    click Devtools "https://github.com/intlify/vue-i18n/blob/master/packages/devtools-types/src/index.ts"
    click Devtools "https://github.com/intlify/vue-i18n/blob/master/packages/devtools-types/package.json"

    click FormatExplorer "https://github.com/intlify/vue-i18n/tree/master/packages/format-explorer/src/"
    click FormatExplorer "https://github.com/intlify/vue-i18n/blob/master/packages/format-explorer/package.json"
    click SizeCheckCore "https://github.com/intlify/vue-i18n/blob/master/packages/size-check-core/src/main.ts"
    click SizeCheckCore "https://github.com/intlify/vue-i18n/blob/master/packages/size-check-core/scripts/size.mjs"
    click SizeCheckVue "https://github.com/intlify/vue-i18n/blob/master/packages/size-check-vue-i18n/src/App.vue"
    click SizeCheckVue "https://github.com/intlify/vue-i18n/blob/master/packages/size-check-vue-i18n/scripts/size.mjs"
    click SizeCheckPetite "https://github.com/intlify/vue-i18n/blob/master/packages/size-check-petite-vue-i18n/src/App.vue"
    click SizeCheckPetite "https://github.com/intlify/vue-i18n/blob/master/packages/size-check-petite-vue-i18n/scripts/size.mjs"

    click Docs "https://github.com/intlify/vue-i18n/tree/master/docs/.vitepress/"
    click Docs "https://github.com/intlify/vue-i18n/tree/master/docs/api/"
    click Docs "https://github.com/intlify/vue-i18n/tree/master/docs/guide/"
    click Docs "https://github.com/intlify/vue-i18n/blob/master/docs/index.md"

    click Examples "https://github.com/intlify/vue-i18n/tree/master/examples/"

    %% Styles
    classDef root fill:#f9f,stroke:#333,stroke-width:1px
    classDef build fill:#fea,stroke:#333,stroke-width:1px
    classDef compiler fill:#f96,stroke:#333,stroke-width:1px
    classDef core fill:#9cf,stroke:#333,stroke-width:1px
    classDef vue fill:#9f9,stroke:#333,stroke-width:1px
    classDef tools fill:#fc9,stroke:#333,stroke-width:1px
    classDef docs fill:#ccc,stroke:#333,stroke-width:1px
    classDef external fill:#ddd,stroke:#333,stroke-width:1px,font-style:italic
```
