# oognuyh/vscode-android-emulator-helper architecture

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

- Interactive diagram: https://gitdiagram.com/oognuyh/vscode-android-emulator-helper
- Repository: https://github.com/oognuyh/vscode-android-emulator-helper

## Overview

##### Main Components
- VS Code Extension Host: At the top level, recognize that the extension runs inside the VS Code environment.
- Extension Entry Point: The file “src/extension.ts” serves as the activator for the extension and registers the various commands.
- Command Modules: Under “src/cmd”, you have separate files (avdmanager.ts, emulator.ts, sdkmanager.ts) that encapsulate functionality related to managing AVDs, running the emulator, and handling SDK packages.
- Data Models: “src/model” contains domain models such as “avd.ts” and “package.ts”. These define the structures of AVDs and packages managed by the extension.
- Utility Functions: “src/utils.ts” holds helper functions shared across components.
- Testing Suite: “src/test” (with its suite files like “extension.test.ts” and “index.ts”) represents the testing infrastructure verifying the behavior of command and utility modules.
- Configuration and Project Metadata: Files such as “package.json”, “tsconfig.json”, and other configuration files define dependencies, build settings, and guidelines for VS Code integration.

##### Relationships and Interactions
- The Extension Entry Point (extension.ts) initializes the extension within the VS Code host and registers the commands.
- When the user invokes a command (via the Command Palette), the corresponding module in “src/cmd” is triggered. For example, “emulator.ts” handles starting the Android emulator.
- The command modules interact with data models (in “src/model”) to parse and represent information about AVDs or packages.
- Utility functions in “src/utils.ts” support different parts of the logic by providing common functionalities such as parsing parameters or formatting commands.
- The system communicates with external tools provided by the Android SDK (emulator, avdmanager, sdkmanager) using command-line interfacing.

##### Architectural Patterns and Design Principles
- Modularity: The separation of concerns is evident – each command (create, delete, run, package management) is isolated, which improves maintainability and testing.
- Command Pattern: The design takes advantage of clear command modules that encapsulate user-initiated actions.
- Testing-Centric: A dedicated “src/test” directory shows a focus on unit/integration testing to ensure reliability.
- Configuration-driven: The inclusion of settings (like "android-emulator-helper.emulator-run-opts" and "avd-creation-opts") allows customization without altering code.

##### Relevant Technologies and Libraries
- TypeScript: The project is built in TypeScript (as seen from tsconfig.json).
- VS Code Extension API: Built as a Visual Studio Code extension, it leverages the VS Code Extension API.
- ESLint for TypeScript: .eslintrc.json indicates linting is configured to enforce code standards.
- Testing Framework: The structure under “src/test” implies the use of a testing framework compatible with the VS Code extension development.

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "VS Code Extension Host"
        EEP("Extension Entry Point"):::entry
        Util("Utility Functions"):::util
        cmd1("AVD Manager Command"):::command
        cmd2("Emulator Command"):::command
        cmd3("SDK Manager Command"):::command
    end

    subgraph "Data Models"
        AVDM("AVD Model"):::model
        PKGM("Package Model"):::model
    end

    subgraph "Testing Suite"
        TR("Test Runner"):::test
        TS1("Extension Test Suite"):::test
        TS2("Index Test Suite"):::test
    end

    subgraph "External Dependencies"
        SDK("Android SDK"):::external
        AVD("AVD Manager"):::external
        Emul("Emulator"):::external
        PT("Platform Tools"):::external
    end

    subgraph "Configuration"
        pkg("package.json"):::config
        tsconf("tsconfig.json"):::config
        eslint(".eslintrc.json"):::config
    end

    %% VS Code Extension Host relationships
    EEP -->|"registers"| cmd1
    EEP -->|"registers"| cmd2
    EEP -->|"registers"| cmd3
    EEP -->|"uses"| Util

    %% Command Modules interacting with Data Models
    cmd1 -->|"parses"| AVDM
    cmd2 -->|"manages"| AVDM
    cmd3 -->|"handles"| PKGM

    %% Command Modules utilizing Utilities
    cmd1 -->|"utilizes"| Util
    cmd2 -->|"utilizes"| Util
    cmd3 -->|"utilizes"| Util

    %% Testing Suite validating components
    cmd1 ---|"testedBy"| TR
    cmd2 ---|"testedBy"| TR
    cmd3 ---|"testedBy"| TR
    Util ---|"testedBy"| TR

    %% Command Modules invoking External Dependencies
    cmd1 -->|"invokes"| AVD
    cmd2 -->|"invokes"| Emul
    cmd3 -->|"invokes"| SDK
    cmd3 -->|"invokes"| PT

    %% Configuration supporting the Extension
    pkg -->|"configures"| EEP
    tsconf -->|"configures"| EEP
    eslint -->|"enforces"| EEP

    %% Click Events
    click EEP "https://github.com/oognuyh/vscode-android-emulator-helper/blob/master/src/extension.ts"
    click cmd1 "https://github.com/oognuyh/vscode-android-emulator-helper/blob/master/src/cmd/avdmanager.ts"
    click cmd2 "https://github.com/oognuyh/vscode-android-emulator-helper/blob/master/src/cmd/emulator.ts"
    click cmd3 "https://github.com/oognuyh/vscode-android-emulator-helper/blob/master/src/cmd/sdkmanager.ts"
    click AVDM "https://github.com/oognuyh/vscode-android-emulator-helper/blob/master/src/model/avd.ts"
    click PKGM "https://github.com/oognuyh/vscode-android-emulator-helper/blob/master/src/model/package.ts"
    click Util "https://github.com/oognuyh/vscode-android-emulator-helper/blob/master/src/utils.ts"
    click TR "https://github.com/oognuyh/vscode-android-emulator-helper/blob/master/src/test/runTest.ts"
    click TS1 "https://github.com/oognuyh/vscode-android-emulator-helper/blob/master/src/test/suite/extension.test.ts"
    click TS2 "https://github.com/oognuyh/vscode-android-emulator-helper/blob/master/src/test/suite/index.ts"
    click pkg "https://github.com/oognuyh/vscode-android-emulator-helper/blob/master/package.json"
    click tsconf "https://github.com/oognuyh/vscode-android-emulator-helper/blob/master/tsconfig.json"
    click eslint "https://github.com/oognuyh/vscode-android-emulator-helper/blob/master/.eslintrc.json"

    %% Styles
    classDef entry fill:#cfe2f3,stroke:#085ff8,stroke-width:2px;
    classDef command fill:#f9cb9c,stroke:#bf9000,stroke-width:2px;
    classDef model fill:#d9ead3,stroke:#38761d,stroke-width:2px;
    classDef util fill:#ead1dc,stroke:#b854a1,stroke-width:2px;
    classDef test fill:#fff2cc,stroke:#bf9000,stroke-width:2px;
    classDef external fill:#d0e0e3,stroke:#115e67,stroke-width:2px;
    classDef config fill:#fce5cd,stroke:#b45f06,stroke-width:2px;
```
