# lambdatest/playwright-sample architecture

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

- Interactive diagram: https://gitdiagram.com/lambdatest/playwright-sample
- Repository: https://github.com/lambdatest/playwright-sample

## Overview

##### Main components
- Developer / CI Environment
– Local machine or GitHub Actions runner (defined in .github/workflows/tests.yml)
– Gitpod workspace (optional dev environment)
- Test Runners & Scripts
– JavaScript/TypeScript (playwright-test-js, playwright-test-ts, playwright-single.js, playwright-parallel.js, etc.)
– CodeceptJS (playwright-codecept-js)
– Cucumber.js (playwright-cucumber-js)
– .NET SpecFlow + xUnit (playwright-csharp-specflow-xunit)
– Plain C# (playwright-csharp)
– Java + JUnit (playwright-java-junit)
– Python samples (playwright-python)
– Jest integration (playwright-jest-js)
- Configuration & Credentials
– Environment variables (LT_USERNAME, LT_ACCESS_KEY)
– Framework config files (playwright.config.js/ts, codecept.conf.js, specflow hooks, pom.xml, package.json)
- LambdaTest Cloud
– Remote browser/device grid (3000+ environments)
– Authentication API (receives credentials over HTTPS)
– Test execution service (spawns browser sessions)
– Dashboard & persistence (stores logs, videos, test metadata)
- External Services
– GitHub (source code, workflows)
– Gitpod (optional)

##### Relationships & data flows
- Developer/CI → Test Runner: invokes npm/`dotnet test`/`mvn test`/`pytest` commands
- Test Runner → LambdaTest Cloud API: establishes WebSocket/REST connection with credentials
- LambdaTest Cloud → Remote Browsers: allocates and runs Playwright sessions on real browsers/devices
- Browser Sessions → LambdaTest Dashboard: streams video, logs, and results back to the cloud
- Developer/CI ← LambdaTest Dashboard: test results fetched via UI or API for reporting

##### Architectural patterns & principles
- Modular multi-language samples: each folder is an independent “adapter” for a language/framework
- Externalized configuration: all credentials and capabilities injected via env vars or config files
- CI integration: GitHub Actions orchestrates automated end-to-end tests on each push
- Service-oriented testing: decoupling test scripts from execution environment (Playwright → LT Cloud)

##### Essential details to capture
- Authentication handshake using LT_USERNAME / LT_ACCESS_KEY
- Playwright commands crossing network boundary into LT Cloud
- Session lifecycle: allocation → execution → reporting
- Storage of artifacts (screenshots, videos, logs)

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Developer and CI
    DevCI["Developer Machine / CI Runner"]:::local
    GitHub["GitHub Actions Trigger"]:::external
    Gitpod["Gitpod Workspace"]:::external

    GitHub -->|"trigger tests"| DevCI
    Gitpod -->|"on-demand run"| DevCI

    %% Test Runners & Scripts
    subgraph "Test Runners & Scripts"
        direction TB
        JS_TS["JavaScript/TypeScript"]:::local
        CodeceptJS["CodeceptJS"]:::local
        CucumberJS["Cucumber.js"]:::local
        CSharp_SF[".NET SpecFlow + xUnit"]:::local
        CSharp["Plain C#"]:::local
        Java_JUnit["Java + JUnit"]:::local
        JavaPlain["Java"]:::local
        Python["Python"]:::local
        Jest["Jest Integration"]:::local
    end

    DevCI -->|"runs tests"| JS_TS
    DevCI --> CodeceptJS
    DevCI --> CucumberJS
    DevCI --> CSharp_SF
    DevCI --> CSharp
    DevCI --> Java_JUnit
    DevCI --> JavaPlain
    DevCI --> Python
    DevCI --> Jest

    %% Configuration & Credentials
    Config["Config & Credentials\n(env vars, config files)"]:::local
    DevCI -->|"loads config"| Config
    JS_TS --> Config
    CodeceptJS --> Config
    CucumberJS --> Config
    CSharp_SF --> Config
    CSharp --> Config
    Java_JUnit --> Config
    JavaPlain --> Config
    Python --> Config
    Jest --> Config

    %% LambdaTest Cloud
    subgraph "LambdaTest Cloud"
        direction TB
        AuthAPI["Authentication API"]:::cloud
        TestExec["Test Execution Service"]:::cloud
        subgraph "Browser Grid"
            direction TB
            Grid["Remote Browser Grid"]:::cloud
        end
        Dashboard["Dashboard & Storage"]:::storage
    end

    Config -->|"credentials"| AuthAPI
    AuthAPI -->|"validate"| TestExec
    TestExec -->|"allocate session"| Grid
    Grid -->|"stream video/logs"| Dashboard
    Dashboard -.->|"reporting/results"| DevCI

    %% External integrations
    GitHub --- DevCI
    Gitpod --- DevCI

    %% Click Events
    click DevCI "https://github.com/lambdatest/playwright-sample/blob/main/.github/workflows/tests.yml"
    click Gitpod "https://github.com/lambdatest/playwright-sample/blob/main/.gitpod.yml"
    click JS_TS "https://github.com/lambdatest/playwright-sample/tree/main/playwright-test-js/"
    click CodeceptJS "https://github.com/lambdatest/playwright-sample/tree/main/playwright-codecept-js/"
    click CucumberJS "https://github.com/lambdatest/playwright-sample/tree/main/playwright-cucumber-js/"
    click CSharp_SF "https://github.com/lambdatest/playwright-sample/tree/main/playwright-csharp-specflow-xunit/"
    click CSharp "https://github.com/lambdatest/playwright-sample/tree/main/playwright-csharp/"
    click Java_JUnit "https://github.com/lambdatest/playwright-sample/tree/main/playwright-java-junit/"
    click JavaPlain "https://github.com/lambdatest/playwright-sample/tree/main/playwright-java/"
    click Python "https://github.com/lambdatest/playwright-sample/tree/main/playwright-python/"
    click Jest "https://github.com/lambdatest/playwright-sample/tree/main/playwright-jest-js/"
    click Config "https://github.com/lambdatest/playwright-sample/blob/main/package.json"

    %% Styles
    classDef local fill:#cce5ff,stroke:#004085,color:#004085
    classDef cloud fill:#c3e6cb,stroke:#155724,color:#155724
    classDef storage fill:#d4edda,stroke:#155724,color:#155724
    classDef external fill:#fff3cd,stroke:#856404,color:#856404
```
