# xotabu4/demo-playwright-workshop architecture

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

- Interactive diagram: https://gitdiagram.com/xotabu4/demo-playwright-workshop
- Repository: https://github.com/xotabu4/demo-playwright-workshop

## Overview

##### Project type and purpose
- This is an end-to-end (E2E) test automation suite built on Playwright (TypeScript, Node.js) for a demo e-commerce application (“shopdemo…”). Its goal is to validate UI flows and API interactions against two deployed storefronts.

##### File structure
- Top-level config & scripts
- playwright.config.ts – Playwright test runner configuration
- package.json, .eslintrc, tsconfig.json
- API layer (api/)
- api.ts, auth.controller.ts, requestHolder.ts, models.d.ts
- Page Object Model (app/)
- abstractClasses.ts
- component/ (reusable UI widgets)
- page/ (pages and page-specific components)
- Fixtures (fixtures/)
- index.ts (shared test fixtures)
- lazy/ (lazy-loaded or on-demand fixtures)
- Miscellaneous helpers (misc/)
- cacheWarmer.ts
- reporters/ (custom Playwright reporters: slowStepReporter.ts, step.ts)
- Test suites (tests/)
- organized by examples, junior, senior, lazy-fixtures, etc.

##### README
- Confirms “demo-playwright-workshop” E2E project
- Provides target URLs for the system under test
- Notes for debugging locators

##### Main components
A. Test Runner & Config
– Playwright CLI (playwright.config.ts)
– Custom reporters in misc/reporters/
B. Page Object Model
– app/page (pages)
– app/component (widgets)
– abstractClasses.ts (base page / component classes)
C. API Abstraction
– api/requestHolder.ts (HTTP client)
– api/auth.controller.ts (auth flows)
– api/models.d.ts (types)
D. Fixtures
– fixtures/index.ts (global fixtures)
– fixtures/lazy (on-demand fixtures)
E. Utility Scripts
– misc/cacheWarmer.ts (warming up state)
F. Test Suites
– tests/ (examples, junior, senior, visual, etc.)
– Organized by skill level and feature area
G. External System Under Test
– UI Endpoints (browser-driven)
– REST API Endpoints (API-driven)
H. Browsers & Network
– Chromium/Firefox/WebKit nodes managed by Playwright
– Outbound HTTP calls for API tests

##### Relationships & interactions
- Test Runner reads playwright.config → registers fixtures, reporters
- Each test imports POM classes (app/) and/or API controllers (api/)
- POM classes drive the browser via Playwright APIs
- API controllers drive HTTP requests via requestHolder
- Fixtures supply common setup/teardown (users, tokens, cart state)
- misc/cacheWarmer preloads data (optional)
- Custom reporters collect step-by-step logs and performance metrics
- Tests execute against the External SUT URLs

##### Architectural patterns & design principles
- Page Object Model for UI tests
- Layered abstraction: test → page/API → browser/HTTP
- Fixture injection for reusable state setup
- Custom reporters for observability
- Modular test suite organization by maturity/feature

##### Elements
- Clear labels: “Playwright Runner”, “Page Objects”, “API Controllers”, “Tests”
- Optional: annotate key files (e.g., playwright.config.ts, abstractClasses.ts)

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Test Orchestration Layer
    subgraph "Test Orchestration"
        direction TB
        Runner["Playwright Runner"]:::runner
        Config["playwright.config.ts"]:::runner
        Reporter1["slowStepReporter"]:::runner
        Reporter2["step Reporter"]:::runner
    end

    %% Test Logic Layer
    subgraph "Test Logic"
        direction TB
        EFTests["examples-fixtures tests"]:::tests
        CETest["capturing-elements test"]:::tests
        LFTest["lazy-fixtures purchase test"]:::tests
        JrTests["junior tests"]:::tests
        SrTests["senior tests"]:::tests
    end

    %% Abstractions Layer
    subgraph "Abstractions"
        direction TB
        subgraph "Page Object Model"
            direction TB
            BaseClasses["abstractClasses.ts"]:::core
            Components["UI Widgets"]:::core
            Pages["Pages"]:::core
        end
        subgraph "API Abstraction"
            direction TB
            APIClient["requestHolder.ts"]:::core
            AuthController["auth.controller.ts"]:::core
            APIModels["models.d.ts"]:::core
            APIIndex["api.ts"]:::core
        end
        subgraph "Fixtures & Utilities"
            direction TB
            Fixtures["fixtures/index.ts"]:::fixture
            LazyFixtures["fixtures/lazy/index.ts"]:::fixture
            CacheWarmer["cacheWarmer.ts"]:::fixture
        end
    end

    %% External System Under Test
    subgraph "External SUT"
        direction TB
        Browser["Browsers (Chromium/Firefox/WebKit)"]:::external
        UIEndpoints[(“shopdemo…” UI)]:::external
        APIEndpoints[(REST API Endpoints)]:::external
    end

    %% Relationships
    Runner -->|uses config| Config
    Runner -->|registers| Fixtures
    Runner -->|registers| Reporter1
    Runner -->|registers| Reporter2

    EFTests -->|import POM/API| BaseClasses
    EFTests --> Pages
    CETest --> Pages
    LFTest --> Fixtures
    JrTests --> Pages
    SrTests --> APIClient

    Pages -->|drive via Playwright| Browser
    Components -->|used by| Pages
    BaseClasses -->|extended by| Pages
    BaseClasses -->|extended by| Components

    APIClient -->|HTTP calls| APIEndpoints
    AuthController --> APIClient
    APIIndex --> APIClient
    APIModels -.-> APIClient

    CacheWarmer -->|preloads data| APIEndpoints
    LazyFixtures -->|on-demand| APIClient

    Browser -->|renders| UIEndpoints

    %% Click Events
    click Config "https://github.com/xotabu4/demo-playwright-workshop/blob/main/playwright.config.ts"
    click Reporter1 "https://github.com/xotabu4/demo-playwright-workshop/blob/main/misc/reporters/slowStepReporter.ts"
    click Reporter2 "https://github.com/xotabu4/demo-playwright-workshop/blob/main/misc/reporters/step.ts"
    click BaseClasses "https://github.com/xotabu4/demo-playwright-workshop/blob/main/app/abstractClasses.ts"
    click Components "https://github.com/xotabu4/demo-playwright-workshop/tree/main/app/component"
    click Pages "https://github.com/xotabu4/demo-playwright-workshop/tree/main/app/page"
    click APIClient "https://github.com/xotabu4/demo-playwright-workshop/blob/main/api/requestHolder.ts"
    click AuthController "https://github.com/xotabu4/demo-playwright-workshop/blob/main/api/auth.controller.ts"
    click APIIndex "https://github.com/xotabu4/demo-playwright-workshop/blob/main/api/api.ts"
    click APIModels "https://github.com/xotabu4/demo-playwright-workshop/blob/main/api/models.d.ts"
    click Fixtures "https://github.com/xotabu4/demo-playwright-workshop/blob/main/fixtures/index.ts"
    click LazyFixtures "https://github.com/xotabu4/demo-playwright-workshop/blob/main/fixtures/lazy/index.ts"
    click CacheWarmer "https://github.com/xotabu4/demo-playwright-workshop/blob/main/misc/cacheWarmer.ts"
    click EFTests "https://github.com/xotabu4/demo-playwright-workshop/blob/main/tests/examples-fixtures/auto.test.ts"
    click CETest "https://github.com/xotabu4/demo-playwright-workshop/blob/main/tests/examples/capturing-elements.test.ts"
    click LFTest "https://github.com/xotabu4/demo-playwright-workshop/blob/main/tests/lazy-fixtures/purchase.test.ts"
    click JrTests "https://github.com/xotabu4/demo-playwright-workshop/tree/main/tests/tests-junior/"
    click SrTests "https://github.com/xotabu4/demo-playwright-workshop/tree/main/tests/tests-senior/"

    %% Styles
    classDef runner fill:#FFA500,stroke:#333,stroke-width:1px
    classDef core fill:#ADD8E6,stroke:#333,stroke-width:1px
    classDef fixture fill:#90EE90,stroke:#333,stroke-width:1px
    classDef tests fill:#FFD700,stroke:#333,stroke-width:1px
    classDef external fill:#D3D3D3,stroke:#333,stroke-width:1px
```
