# embroider-build/embroider architecture

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

- Interactive diagram: https://gitdiagram.com/embroider-build/embroider
- Repository: https://github.com/embroider-build/embroider

## Overview

##### Main Components
- Core Build & Translation Engine: Start with packages like “packages/core” and “packages/compat”. These are the heart of the translation layer that processes Ember apps and addons.
- Integration Adapters: Include components that bridge the core logic with different bundlers or runtimes. For example, “packages/vite”, “packages/webpack”, and “packages/babel-loader-9”. They demonstrate how Embroider plugs into modern build tooling.
- Addon Support & Compatibility: Represent modules like “packages/addon-dev”, “packages/addon-shim”, and “packages/macros”. These provide support specifically for transforming addon code, handling macros, and managing addon dependencies.
- Utilities & Shared Internals: There are packages like “packages/shared-internals” and “packages/util” that supply helper functions, caching, and file system operations which are used by many parts of the system.
- Other Supporting Tools: Don’t forget ancillary tooling (like “packages/hbs-loader”, “packages/reverse-exports”, and “packages/config-meta-loader”) that handle specific responsibilities (template pre-compiling, module re-exporting, and configuration metadata).

##### Representing Relationships and Interactions
– Show that the addon-support packages and macros plug into the core engine as well as interact with each other. For instance, “addon-dev” and “addon-shim” are for transforming addon code in a manner that is consistent with the v2 addon format.
- Modules within the monorepo are highly interdependent. Indicate the reliance of multiple packages on shared utilities from “shared-internals” and “util”.

##### Architectural Patterns and Design Principles
- Plugin-based Architecture: Emphasize that the design relies on a plug-and-play approach. The core transformation logic delegates tasks to various plugins and integrations (Vite, Webpack, Babel, etc.) with clearly defined interfaces.
- Layered Architecture: Show the separation between the core/resolver logic and the build-system-specific adapters. This makes the architecture extensible and modular.
- Environment Flexibility: Indicate that options and environment variables (like EMBROIDER_WORKING_DIRECTORY) provide configuration at build time that can affect how these layers interact.

##### Technologies, Frameworks, and Libraries
- That Ember itself is the base target. The system integrates modern bundlers like Vite and Webpack.
- Babel-related components and testing infrastructure (like Jest and QUnit support indicated by various configuration files) that are part of the development ecosystem.
- Use of GitHub actions and CI configuration files shows that the repository is set up for continuous integration and automated testing.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Core Build & Translation Engine
    subgraph "Core Build & Translation Engine"
        CORE["Core (packages/core)"]:::core
        COMPAT["Compat (packages/compat)"]:::core
    end

    %% Integration Adapters
    subgraph "Integration Adapters"
        VITE["Vite Integration Adapter"]:::adapter
        WEBPACK["Webpack Integration Adapter"]:::adapter
        BABEL["Babel Loader Adapter"]:::adapter
    end

    %% Addon Support & Compatibility
    subgraph "Addon Support & Compatibility"
        ADDONDEV["Addon Dev"]:::addon
        ADDONSHIM["Addon Shim"]:::addon
        MACROS["Macros Processor"]:::addon
    end

    %% Utilities & Shared Internals
    subgraph "Utilities & Shared Internals"
        SHARED["Shared Internals"]:::utility
        UTIL["Util Functions"]:::utility
    end

    %% Other Supporting Tools
    subgraph "Other Supporting Tools"
        HBS["HBS Loader"]:::support
        REV["Reverse Exports"]:::support
        CONFIG["Config Meta Loader"]:::support
    end

    %% Testing & CI/CD Infrastructure
    CI["CI/CD Workflows"]:::ci

    %% Relationships: Integration Adapters to Core
    VITE -->|"uses"| CORE
    VITE -->|"uses"| COMPAT
    WEBPACK -->|"uses"| CORE
    WEBPACK -->|"uses"| COMPAT
    BABEL -->|"uses"| CORE
    BABEL -->|"uses"| COMPAT

    %% Relationships: Addon Support to Core
    ADDONDEV -->|"transforms"| CORE
    ADDONDEV -->|"transforms"| COMPAT
    ADDONSHIM -->|"transforms"| CORE
    ADDONSHIM -->|"transforms"| COMPAT
    MACROS -->|"processes"| CORE
    MACROS -->|"processes"| COMPAT

    %% Relationships: Utilities Support
    SHARED -->|"supports"| CORE
    SHARED -->|"supports"| VITE
    UTIL -->|"supports"| COMPAT
    UTIL -->|"supports"| ADDONDEV

    %% Relationships: Other Supporting Tools to Core
    HBS -->|"pre-compiles"| CORE
    REV -->|"re-exports"| CORE
    CONFIG -->|"loadsMeta"| CORE

    %% Relationships: CI/CD Validation
    CI -.->|"validates"| CORE
    CI -.->|"validates"| VITE
    CI -.->|"validates"| ADDONDEV

    %% Click Events
    click CORE "https://github.com/embroider-build/embroider/tree/main/packages/core"
    click COMPAT "https://github.com/embroider-build/embroider/tree/main/packages/compat"

    click VITE "https://github.com/embroider-build/embroider/tree/main/packages/vite"
    click WEBPACK "https://github.com/embroider-build/embroider/tree/main/packages/webpack"
    click BABEL "https://github.com/embroider-build/embroider/tree/main/packages/babel-loader-9"

    click ADDONDEV "https://github.com/embroider-build/embroider/tree/main/packages/addon-dev"
    click ADDONSHIM "https://github.com/embroider-build/embroider/tree/main/packages/addon-shim"
    click MACROS "https://github.com/embroider-build/embroider/tree/main/packages/macros"

    click SHARED "https://github.com/embroider-build/embroider/tree/main/packages/shared-internals"
    click UTIL "https://github.com/embroider-build/embroider/tree/main/packages/util"

    click HBS "https://github.com/embroider-build/embroider/tree/main/packages/hbs-loader"
    click REV "https://github.com/embroider-build/embroider/tree/main/packages/reverse-exports"
    click CONFIG "https://github.com/embroider-build/embroider/tree/main/packages/config-meta-loader"

    click CI "https://github.com/embroider-build/embroider/tree/main/.github/workflows"

    %% Styles
    classDef core fill:#FFD700,stroke:#333,stroke-width:2px;
    classDef adapter fill:#87CEEB,stroke:#333,stroke-width:2px;
    classDef addon fill:#90EE90,stroke:#333,stroke-width:2px;
    classDef utility fill:#FFB6C1,stroke:#333,stroke-width:2px;
    classDef support fill:#D8BFD8,stroke:#333,stroke-width:2px;
    classDef ci fill:#D3D3D3,stroke:#333,stroke-width:2px;
```
