# saucelabs/visual-sdks architecture

> Architecture diagram of the GitHub repository saucelabs/visual-sdks, 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/saucelabs/visual-sdks
- Repository: https://github.com/saucelabs/visual-sdks

## Overview

##### High-Level Architecture Components

a. Core SDKs Layer
- Five main SDK implementations (.NET, Java, JavaScript/TypeScript, Python, Espresso)
- Each SDK should be represented as a major component

b. Testing Framework Integration Layer
- Cypress, Nightwatch, Playwright, WebDriverIO, Storybook (JavaScript)
- JUnit/TestNG (Java)
- Robot Framework (Python)
- Espresso (Android)

c. Common Infrastructure Layer
- GraphQL API Client
- Authentication Handling
- Visual Testing Core Features

##### Component Relationships

a. SDK Implementation Pattern (for each SDK):
- Testing Framework Integration → SDK Core → GraphQL API → Sauce Labs Visual Service

b. Shared Components:
- Common GraphQL operations shared across SDKs
- Shared visual testing features (snapshots, diffs, builds)

##### Detailed Component Breakdown

For each SDK, include these elements:

**SDK Core**
- API Client
- GraphQL Operations
- Authentication
- Visual Testing Features
- Build Management
- Snapshot Handling
- Diff Analysis
- Framework-Specific Adapters

##### Implementation Details

Key architectural patterns:
- GraphQL client implementation
- Build management system
- Visual comparison workflow
- Framework-specific adapters

##### Data Flow

Following flows:
**Test Framework → SDK → Visual API → Results Processing → Test Reports**

##### Integration Points

Highlight:
- CI/CD integration (.github/workflows)
- Cross-language compatibility
- Framework-specific adapters

##### Version management and release workflow

Key Elements to Include:

**┌─ Testing Frameworks Layer ─┐**
- Cypress, JUnit, Robot... │
- SDK Layer ─────────┤
- .NET, Java, JS, Python   │
- Common Core Layer ────┤
- GraphQL, Auth, Visual    │
- External APIs ──────┘

Remember to:
- Clear separation of concerns
- Cross-SDK commonalities
- Error handling and retry mechanisms
- Test result processing flow

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph Testing["Testing Framework Integration Layer"]
        direction TB
        Cypress["Cypress"]:::framework
        Nightwatch["Nightwatch"]:::framework
        Playwright["Playwright"]:::framework
        WDIO["WebDriverIO"]:::framework
        Storybook["Storybook"]:::framework
        JUnit["JUnit/TestNG"]:::framework
        Robot["Robot Framework"]:::framework
        Espresso["Espresso Tests"]:::framework
    end

    subgraph SDKs["Core SDKs Layer"]
        direction TB
        DotNet[".NET SDK"]:::sdk
        Java["Java SDK"]:::sdk
        JavaScript["JavaScript SDK"]:::sdk
        Python["Python SDK"]:::sdk
        EspressoSDK["Espresso SDK"]:::sdk
    end

    subgraph Common["Common Infrastructure Layer"]
        direction TB
        subgraph GraphQL["GraphQL API Clients"]
            DotNetGraphQL[".NET GraphQL"]:::graphql
            JavaGraphQL["Java GraphQL"]:::graphql
            JSGraphQL["JavaScript GraphQL"]:::graphql
            PythonGraphQL["Python GraphQL"]:::graphql
        end

        subgraph Auth["Authentication"]
            DotNetAuth[".NET Auth"]:::auth
            JavaAuth["Java Auth"]:::auth
        end

        subgraph Core["Visual Testing Core"]
            DotNetCore[".NET Core"]:::core
            JavaCore["Java Core"]:::core
            JSCore["JavaScript Core"]:::core
            PythonCore["Python Core"]:::core
        end
    end

    SauceVisual["Sauce Labs Visual Service"]:::external

    %% Framework to SDK connections
    Cypress --> JavaScript
    Nightwatch --> JavaScript
    Playwright --> JavaScript
    WDIO --> JavaScript
    Storybook --> JavaScript
    JUnit --> Java
    Robot --> Python
    Espresso --> EspressoSDK

    %% SDK to GraphQL connections
    DotNet --> DotNetGraphQL
    Java --> JavaGraphQL
    JavaScript --> JSGraphQL
    Python --> PythonGraphQL
    EspressoSDK --> JavaGraphQL

    %% SDK to Auth connections
    DotNet --> DotNetAuth
    Java --> JavaAuth

    %% SDK to Core connections
    DotNet --> DotNetCore
    Java --> JavaCore
    JavaScript --> JSCore
    Python --> PythonCore

    %% Common layer to Service connections
    DotNetGraphQL --> SauceVisual
    JavaGraphQL --> SauceVisual
    JSGraphQL --> SauceVisual
    PythonGraphQL --> SauceVisual

    %% Styling
    classDef framework fill:#90EE90,stroke:#333,stroke-width:2px
    classDef sdk fill:#87CEEB,stroke:#333,stroke-width:2px
    classDef graphql fill:#FFA500,stroke:#333,stroke-width:2px
    classDef auth fill:#DDA0DD,stroke:#333,stroke-width:2px
    classDef core fill:#9370DB,stroke:#333,stroke-width:2px
    classDef external fill:#D3D3D3,stroke:#333,stroke-width:2px

    %% Click events
    click Cypress "https://github.com/saucelabs/visual-sdks/tree/main/visual-js/visual-cypress/"
    click Nightwatch "https://github.com/saucelabs/visual-sdks/tree/main/visual-js/visual-nightwatch/"
    click Playwright "https://github.com/saucelabs/visual-sdks/tree/main/visual-js/visual-playwright/"
    click WDIO "https://github.com/saucelabs/visual-sdks/tree/main/visual-js/visual-wdio/"
    click Storybook "https://github.com/saucelabs/visual-sdks/tree/main/visual-js/visual-storybook/"
    click JUnit "https://github.com/saucelabs/visual-sdks/tree/main/visual-java/src/main/java/com/saucelabs/visual/junit5/"
    click Robot "https://github.com/saucelabs/visual-sdks/blob/main/visual-python/src/saucelabs_visual/frameworks/robot.py"
    click Espresso "https://github.com/saucelabs/visual-sdks/tree/main/visual-espresso/visual/src/main/java/com/saucelabs/visual/espresso/"
    click DotNet "https://github.com/saucelabs/visual-sdks/tree/main/visual-dotnet/SauceLabs.Visual/"
    click Java "https://github.com/saucelabs/visual-sdks/tree/main/visual-java/src/main/java/com/saucelabs/visual/"
    click JavaScript "https://github.com/saucelabs/visual-sdks/tree/main/visual-js/visual/"
    click Python "https://github.com/saucelabs/visual-sdks/tree/main/visual-python/src/saucelabs_visual/"
    click EspressoSDK "https://github.com/saucelabs/visual-sdks/tree/main/visual-espresso/visual/src/main/java/com/saucelabs/visual/"
    click DotNetGraphQL "https://github.com/saucelabs/visual-sdks/tree/main/visual-dotnet/SauceLabs.Visual/GraphQL/"
    click JavaGraphQL "https://github.com/saucelabs/visual-sdks/tree/main/visual-java/src/main/java/com/saucelabs/visual/graphql/"
    click JSGraphQL "https://github.com/saucelabs/visual-sdks/tree/main/visual-js/visual/src/graphql/"
    click PythonGraphQL "https://github.com/saucelabs/visual-sdks/blob/main/visual-python/src/saucelabs_visual/client.py"
    click DotNetAuth "https://github.com/saucelabs/visual-sdks/blob/main/visual-dotnet/SauceLabs.Visual/Utils/AuthenticatedGraphQLRequest.cs"
    click JavaAuth "https://github.com/saucelabs/visual-sdks/blob/main/visual-java/src/main/java/com/saucelabs/visual/utils/EnvironmentVariables.java"
    click DotNetCore "https://github.com/saucelabs/visual-sdks/blob/main/visual-dotnet/SauceLabs.Visual/VisualApi.cs"
    click JavaCore "https://github.com/saucelabs/visual-sdks/blob/main/visual-java/src/main/java/com/saucelabs/visual/VisualApi.java"
    click JSCore "https://github.com/saucelabs/visual-sdks/blob/main/visual-js/visual/src/common/api.ts"
    click PythonCore "https://github.com/saucelabs/visual-sdks/blob/main/visual-python/src/saucelabs_visual/client.py"
```
