# expo/vscode-expo architecture

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

- Interactive diagram: https://gitdiagram.com/expo/vscode-expo
- Repository: https://github.com/expo/vscode-expo

## Overview

##### Main Components
- Core Extension Entry Point: The extension’s main file (such as src/extension.ts) initializes and registers various commands.
- Expo Functionality Modules: The “expo” folder (src/expo) contains modules that handle bundling, manifest generation, CLI integration, and other Expo-specific tasks.
- Preview Services: The “preview” folder provides functionality for live previews of native files and manifests. This is crucial to visually demonstrate how app configurations affect generated native assets.
- Utility & Helper Libraries: Modules under src/utils and src/packages (for config-plugins, configuration, and plist management) support core business logic.
- Testing and Automation: The testing folders and scripts (under src/__tests__, test, scripts, and GitHub workflows) represent the quality assurance and CI/CD automation pipeline.
- Build & Deployment: Configuration files (.eslintrc.js, .prettierrc.js, package.json, webpack.config.js, GitHub Actions workflows) represent build automation, code linting, and continuous integration.

##### Relationships and Data Flow
- The VS Code Extension Host initializes the extension by executing the entry point (src/extension.ts) which registers a set of commands (e.g., for debugging, previewing, and providing IntelliSense).
- User-initiated commands trigger interactions with the Expo modules (src/expo) to fetch or generate configuration details.
- The preview components (src/preview) subscribe to configuration changes and provide live visual feedback, leveraging output from the Expo or configuration modules.
- Utility libraries support both Expo and preview modules by handling file operations, caching, and telemetry.
- Testing components validate all modules, ensuring that each part of the system (expo, preview, utilities) behaves as expected.
- Build tools and GitHub workflows automate testing, code analysis, and publishing to both the VS Code Marketplace and Open VSX.

##### Architectural Patterns and Technologies
- Modular Architecture: Clear separation of concerns among VS Code integration, Expo-specific logic, preview functionalities, and underlying utilities.
- Command Registration Pattern: The extension registers VS Code commands that map user actions to backend logic.
- Plugin/Extension Patterns: The design leverages the standard IDE extension model of VS Code.
- CI/CD Integration: GitHub Actions workflows for testing, relesing, and publishing ensure that code quality is maintained.
- External Dependencies: The extension relies on Expo’s CLI and configuration schemas (e.g., eas.json, app.json) as well as configuration files for native projects on Android and iOS.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% VS Code Integration Layer
    subgraph "VS Code Integration"
        VSE["VS Code Extension Host"]:::integration
        EXT["Core Extension Entry Point"]:::integration
    end
    VSE -->|"initializes"| EXT

    %% Expo Functionality Modules
    subgraph "Expo Modules"
        EXPO1["Expo Bundler"]:::business
        EXPO2["Expo CLI Integration"]:::business
        EXPO3["Manifest Generator"]:::business
        EXPO4["Plugin Handler"]:::business
        EXPO5["Project Manager"]:::business
    end
    EXT -->|"registers-commands"| EXPO1
    EXT -->|"registers-commands"| EXPO2
    EXT -->|"registers-commands"| EXPO3
    EXT -->|"registers-commands"| EXPO4
    EXT -->|"registers-commands"| EXPO5

    %% Preview Services
    subgraph "Preview Services"
        PREV1["Code Provider"]:::business
        PREV2["Expo Config Code Provider"]:::business
        PREV3["Introspect Code Provider"]:::business
        PREV4["Preview Setup"]:::business
    end
    EXPO3 -->|"produces-config"| PREV1
    EXPO3 -->|"produces-config"| PREV2
    EXPO3 -->|"produces-config"| PREV3
    EXPO3 -->|"produces-config"| PREV4

    %% Utility & Helper Libraries
    subgraph "Utility Libraries"
        UTIL1["File Utils"]:::utility
        UTIL2["Cache Utils"]:::utility
        UTIL3["Telemetry Utils"]:::utility
        PKG1["Config Plugins"]:::utility
        PKG2["Configuration Helper"]:::utility
        PKG3["Plist Management"]:::utility
        PKG4["Prebuild Config"]:::utility
    end
    EXPO2 -->|"utilizes"| UTIL1
    EXPO2 -->|"utilizes"| UTIL2
    PREV1 -->|"utilizes"| UTIL3
    EXPO4 -->|"utilizes"| PKG1
    EXPO5 -->|"utilizes"| PKG2
    EXPO3 -->|"utilizes"| PKG3
    PREV4 -->|"utilizes"| PKG4

    %% Testing & Automation
    subgraph "Testing & Automation"
        T1["Module Testing (src/__tests__)"]:::testing
        T2["Testing Fixtures (test)"]:::testing
        T3["Automation Scripts (scripts)"]:::testing
    end
    EXT -->|"validated-by"| T1
    EXPO1 -->|"validated-by"| T1
    PREV1 -->|"validated-by"| T1
    UTIL1 -->|"validated-by"| T1

    %% Build & Deployment
    subgraph "Build & Deployment"
        B1["ESLint Config"]:::build
        B2["Prettier Config"]:::build
        B3["Package JSON"]:::build
        B4["Webpack Config"]:::build
        B5["CI/CD Workflows"]:::build
        B6["GitHub Actions"]:::build
    end
    EXT -->|"build-triggers"| B1
    B1 --> B2
    B2 --> B3
    B3 --> B4
    B4 -->|"automated-by"| B5
    B5 --> B6

    %% Click Events
    click VSE "https://github.com/expo/vscode-expo/blob/main/src/extension.ts"
    click EXT "https://github.com/expo/vscode-expo/blob/main/src/extension.ts"
    click EXPO1 "https://github.com/expo/vscode-expo/blob/main/src/expo/bundler.ts"
    click EXPO2 "https://github.com/expo/vscode-expo/blob/main/src/expo/cli.ts"
    click EXPO3 "https://github.com/expo/vscode-expo/blob/main/src/expo/manifest.ts"
    click EXPO4 "https://github.com/expo/vscode-expo/blob/main/src/expo/plugin.ts"
    click EXPO5 "https://github.com/expo/vscode-expo/blob/main/src/expo/project.ts"
    click PREV1 "https://github.com/expo/vscode-expo/blob/main/src/preview/CodeProvider.ts"
    click PREV2 "https://github.com/expo/vscode-expo/blob/main/src/preview/ExpoConfigCodeProvider.ts"
    click PREV3 "https://github.com/expo/vscode-expo/blob/main/src/preview/IntrospectCodeProvider.ts"
    click PREV4 "https://github.com/expo/vscode-expo/blob/main/src/preview/setupPreview.ts"
    click UTIL1 "https://github.com/expo/vscode-expo/blob/main/src/utils/file.ts"
    click UTIL2 "https://github.com/expo/vscode-expo/blob/main/src/utils/cache.ts"
    click UTIL3 "https://github.com/expo/vscode-expo/blob/main/src/utils/telemetry.ts"
    click PKG1 "https://github.com/expo/vscode-expo/blob/main/src/packages/config-plugins.ts"
    click PKG2 "https://github.com/expo/vscode-expo/blob/main/src/packages/config.ts"
    click PKG3 "https://github.com/expo/vscode-expo/blob/main/src/packages/plist.ts"
    click PKG4 "https://github.com/expo/vscode-expo/blob/main/src/packages/prebuild-config.ts"
    click T1 "https://github.com/expo/vscode-expo/tree/main/src/__tests__"
    click T2 "https://github.com/expo/vscode-expo/tree/main/test/fixture/*"
    click T3 "https://github.com/expo/vscode-expo/blob/main/scripts/schema-eas-workflow.js"
    click B1 "https://github.com/expo/vscode-expo/blob/main/.eslintrc.js"
    click B2 "https://github.com/expo/vscode-expo/blob/main/.prettierrc.js"
    click B3 "https://github.com/expo/vscode-expo/blob/main/package.json"
    click B4 "https://github.com/expo/vscode-expo/blob/main/webpack.config.js"
    click B5 "https://github.com/expo/vscode-expo/tree/main/.github/workflows"
    click B6 "https://github.com/expo/vscode-expo/tree/main/.github/actions"

    %% Styles
    classDef integration fill:#a2d2ff,stroke:#000,stroke-width:1px;
    classDef business fill:#ffd6a5,stroke:#000,stroke-width:1px;
    classDef utility fill:#caffbf,stroke:#000,stroke-width:1px;
    classDef testing fill:#ffadad,stroke:#000,stroke-width:1px;
    classDef build fill:#fdffb6,stroke:#000,stroke-width:1px;
```
