# microsoft/playwright-vscode architecture

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

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

## Overview

##### External Components
- Playwright Browser Instances
- Test Files in Workspace
- Trace Viewer UI
- Recording Browser Session

a. Primary Flows:
- VS Code Extension → Playwright Test CLI
- Test Server ↔ Browser Instances
- Extension Host ↔ Test Model
- UI Components ↔ Core Services

b. Secondary Flows:
- Settings Model → Configuration
- Workspace Observer → Test Files
- Debug Integration → Browser Controller

##### Key Integration Points

a. VS Code Integration
- Test Explorer API
- Debug Protocol
- Terminal API
- Workspace API

b. Playwright Integration
- Test Runner
- Browser Control
- Recording API
- Trace Viewer

##### Architectural Patterns to Highlight
- Event-based communication (src/upstream/events.ts)
- Reporter pattern (src/oopReporter.ts)
- Transport layer abstraction (src/transport.ts)

Use the following visualization guidelines:

##### Layer Organization
- Top: UI/Extension Interface
- Middle: Core Services
- Bottom: Playwright Integration

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Styles and classes
    classDef vscode fill:#4a9eff,color:white
    classDef playwright fill:#2ecc71,color:white
    classDef ui fill:#e67e22,color:white
    classDef external fill:#95a5a6,color:white
    
    %% Main VS Code Extension Host
    subgraph VSCodeHost["VS Code Extension Host"]
        EntryPoint["Extension Entry Point"]:::vscode
        TestExplorer["Test Explorer Integration"]:::vscode
        DebugInt["Debug Integration"]:::vscode
        CommandPalette["Command Palette"]:::vscode
    end

    %% Core Services Layer
    subgraph CoreServices["Core Services Layer"]
        TestRunner["Test Runner"]:::playwright
        TestServer["Test Server"]:::playwright
        BrowserCtrl["Browser Controller"]:::playwright
        Installer["Installer Service"]:::playwright
    end

    %% UI Components
    subgraph UIComponents["UI Components"]
        SettingsView["Settings View"]:::ui
        LocatorsView["Locators View"]:::ui
        TraceViewer["Trace Viewer"]:::ui
        TerminalInt["Terminal Integration"]:::ui
    end

    %% Test Management
    subgraph TestMgmt["Test Management"]
        TestModel["Test Model"]:::vscode
        TestTree["Test Tree"]:::vscode
        WorkspaceObs["Workspace Observer"]:::vscode
    end

    %% Integration Systems
    subgraph IntegrationSystems["Integration Systems"]
        EventSystem["Event System"]:::playwright
        Reporter["Reporter System"]:::playwright
        Transport["Transport Layer"]:::playwright
        L10N["Localization"]:::vscode
        DebugHighlight["Debug Highlighting"]:::vscode
        Settings["Settings Model"]:::vscode
    end

    %% External Components
    Browser["Playwright Browser Instances"]:::external
    TestFiles["Test Files in Workspace"]:::external
    TraceUI["Trace Viewer UI"]:::external
    RecordingSession["Recording Browser Session"]:::external

    %% Relationships
    EntryPoint --> TestExplorer
    EntryPoint --> DebugInt
    EntryPoint --> CommandPalette
    
    TestRunner --> TestServer
    TestServer <--> BrowserCtrl
    BrowserCtrl <--> Browser
    
    TestModel --> TestTree
    WorkspaceObs --> TestFiles
    
    DebugInt --> BrowserCtrl
    DebugInt --> DebugHighlight
    
    Transport --> TestServer
    EventSystem --> Reporter
    
    SettingsView --> Settings
    LocatorsView --> BrowserCtrl
    TraceViewer --> TraceUI
    TerminalInt --> TestRunner

    %% Click events for component mapping
    click EntryPoint "https://github.com/microsoft/playwright-vscode/blob/main/src/extension.ts"
    click TestRunner "https://github.com/microsoft/playwright-vscode/blob/main/src/playwrightTestCLI.ts"
    click TestServer "https://github.com/microsoft/playwright-vscode/blob/main/src/playwrightTestServer.ts"
    click BrowserCtrl "https://github.com/microsoft/playwright-vscode/blob/main/src/reusedBrowser.ts"
    click Installer "https://github.com/microsoft/playwright-vscode/blob/main/src/installer.ts"
    click SettingsView "https://github.com/microsoft/playwright-vscode/blob/main/src/settingsView.ts"
    click LocatorsView "https://github.com/microsoft/playwright-vscode/blob/main/src/locatorsView.ts"
    click TraceViewer "https://github.com/microsoft/playwright-vscode/blob/main/src/traceViewer.ts"
    click TerminalInt "https://github.com/microsoft/playwright-vscode/blob/main/src/terminalLinkProvider.ts"
    click TestModel "https://github.com/microsoft/playwright-vscode/blob/main/src/testModel.ts"
    click TestTree "https://github.com/microsoft/playwright-vscode/blob/main/src/testTree.ts"
    click WorkspaceObs "https://github.com/microsoft/playwright-vscode/blob/main/src/workspaceObserver.ts"
    click EventSystem "https://github.com/microsoft/playwright-vscode/blob/main/src/upstream/events.ts"
    click Reporter "https://github.com/microsoft/playwright-vscode/blob/main/src/oopReporter.ts"
    click Transport "https://github.com/microsoft/playwright-vscode/blob/main/src/transport.ts"
    click DebugInt "https://github.com/microsoft/playwright-vscode/blob/main/src/debugTransform.ts"
    click Settings "https://github.com/microsoft/playwright-vscode/blob/main/src/settingsModel.ts"
    click DebugHighlight "https://github.com/microsoft/playwright-vscode/blob/main/src/debugHighlight.ts"
    click L10N "https://github.com/microsoft/playwright-vscode/blob/main/l10n/bundle.l10n.json"

    %% Legend
    subgraph Legend
        L1["VS Code Components"]:::vscode
        L2["Playwright Components"]:::playwright
        L3["UI Components"]:::ui
        L4["External Systems"]:::external
    end
```
