# mahbub091/playwright_ts_project architecture

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

- Interactive diagram: https://gitdiagram.com/mahbub091/playwright_ts_project
- Repository: https://github.com/mahbub091/playwright_ts_project

## Overview

##### Project Type & Purpose
- This is an end-to-end (E2E) test automation framework using Playwright + TypeScript.
- It follows a hybrid approach with the Page Object Model (POM), reusable utilities, externalized test data, and CI/CD integration.

##### Key Architectural Components
a. Configuration Layer
- playwright.config.ts – global Playwright settings (browsers, timeouts, reporters)
- package.json / package-lock.json – dependencies and scripts
- .github/workflows/main.yml – CI pipeline for running tests on each push/PR
b. Test Suites
- /tests – entry points (e.g., loginTest.spec.ts, lambdaTestPlayground.spec.ts)
- These invoke fixtures and POM classes.
c. Page Object Model (POM) Layer
- /pom – encapsulates page‐specific locators & actions (loginPage.ts, accountPage.ts, lambdaHomePage.ts)
- Each class exposes methods representing UI operations.
d. Utilities Layer
- /utilities – shared helpers
– fixtures.ts (Playwright fixtures for setup/teardown)
– logger.ts (custom logging)
– utils.ts (generic functions)
– valueProvider.ts (dynamic value generation)
e. Test Data Layer
- /testData – JSON files (globalData.json, lambda.json) for environment-specific inputs
- Loaded by utilities or direct import in tests.
f. Playwright Engine & Browsers
- Underlying Playwright library launching Chromium/Firefox/WebKit
- Browser instances spin up per fixture configuration.

##### Interactions & Data Flow
1. CI/CD Trigger (GitHub Actions) →
2. Installs npm deps →
3. Runs `npx playwright test` (or npm script) →
4. Test Runner reads playwright.config.ts →
5. Fixtures initialize browser contexts →
6. Test Spec imports test data & utilities →
7. Test Spec calls POM methods →
8. POM uses Playwright APIs to interact with the browser →
9. Utilities log results, read/write test data →
10. Test Runner gathers reports and artifacts

##### Architectural Patterns & Principles
- **Page Object Model**: separates page concerns into classes.
- **Layered Architecture**: clear separation between test scripts, page abstractions, utilities, and data.
- **Configuration as Code**: all settings externalized in config files.
- **CI/CD Integration**: pipeline runs headless tests on each commit.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% CI/CD Layer
    subgraph "CI/CD Pipeline" 
        direction TB
        CI["GitHub Actions"]:::ci
        CI -->|"install deps"| NPM["package.json / package-lock.json"]:::config
        click CI "https://github.com/mahbub091/playwright_ts_project/blob/master/.github/workflows/main.yml"
        click NPM "https://github.com/mahbub091/playwright_ts_project/blob/master/package.json"
        click NPM "https://github.com/mahbub091/playwright_ts_project/blob/master/package-lock.json"
    end

    %% Configuration Layer
    subgraph "Configuration Layer"
        direction TB
        CFG["playwright.config.ts"]:::config
        click CFG "https://github.com/mahbub091/playwright_ts_project/blob/master/playwright.config.ts"
    end

    %% Test Suites Layer
    subgraph "Test Suites" 
        direction TB
        TS1["loginTest.spec.ts"]:::tests
        TS2["lambdaTestPlayground.spec.ts"]:::tests
        click TS1 "https://github.com/mahbub091/playwright_ts_project/blob/master/tests/loginTest.spec.ts"
        click TS2 "https://github.com/mahbub091/playwright_ts_project/blob/master/tests/lambdaTestPlayground.spec.ts"
    end

    %% POM Layer
    subgraph "Page Object Model (POM)" 
        direction TB
        POM1["loginPage.ts"]:::pom
        POM2["accountPage.ts"]:::pom
        POM3["lambdaHomePage.ts"]:::pom
        click POM1 "https://github.com/mahbub091/playwright_ts_project/blob/master/pom/loginPage.ts"
        click POM2 "https://github.com/mahbub091/playwright_ts_project/blob/master/pom/accountPage.ts"
        click POM3 "https://github.com/mahbub091/playwright_ts_project/blob/master/pom/lambdaHomePage.ts"
    end

    %% Utilities Layer
    subgraph "Utilities" 
        direction TB
        U1["fixtures.ts"]:::utils
        U2["logger.ts"]:::utils
        U3["utils.ts"]:::utils
        U4["valueProvider.ts"]:::utils
        click U1 "https://github.com/mahbub091/playwright_ts_project/blob/master/utilities/fixtures.ts"
        click U2 "https://github.com/mahbub091/playwright_ts_project/blob/master/utilities/logger.ts"
        click U3 "https://github.com/mahbub091/playwright_ts_project/blob/master/utilities/utils.ts"
        click U4 "https://github.com/mahbub091/playwright_ts_project/blob/master/utilities/valueProvider.ts"
    end

    %% Test Data Layer
    subgraph "Test Data" 
        direction TB
        D1["globalData.json"]:::data
        D2["lambda.json"]:::data
        click D1 "https://github.com/mahbub091/playwright_ts_project/blob/master/testData/globalData.json"
        click D2 "https://github.com/mahbub091/playwright_ts_project/blob/master/testData/lambda.json"
    end

    %% Playwright Engine & Browsers
    subgraph "Playwright Engine & Browsers"
        direction TB
        ENG["Playwright Library"]:::engine
        BROW["Chromium/Firefox/WebKit"]:::engine
    end

    %% Flow of interactions
    CI -->|"run tests"| TR["Test Runner"]:::runner
    TR -->|"reads config"| CFG
    TR -->|"initializes fixtures"| U1
    TS1 -->|"imports fixtures & data"| U1
    TS2 -->|"imports fixtures & data"| U1
    TS1 -->|"calls POM methods"| POM1
    TS1 -->|"calls POM methods"| POM2
    TS2 -->|"calls POM methods"| POM3
    POM1 -->|"uses Playwright APIs"| ENG
    POM2 -->|"uses Playwright APIs"| ENG
    POM3 -->|"uses Playwright APIs"| ENG
    ENG -->|"launches browsers"| BROW
    TS1 -->|"loads data"| D1
    TS1 -->|"loads data"| D2
    TS2 -->|"loads data"| D1
    TS2 -->|"loads data"| D2
    U2 -->|"logs results"| TR
    U3 -->|"utility functions"| POM1
    U4 -->|"value generation"| POM3
    TR -->|"gathers reports"| CI

    %% Styles
    classDef ci fill:#D0E6A5,stroke:#88B04B,stroke-width:2px;
    classDef config fill:#AEDFF7,stroke:#3A9AD9,stroke-width:2px;
    classDef tests fill:#C3E88D,stroke:#6FAB3C,stroke-width:2px;
    classDef pom fill:#F9E79F,stroke:#D4AC0D,stroke-width:2px;
    classDef utils fill:#F5B7B1,stroke:#C0392B,stroke-width:2px;
    classDef data fill:#D7BDE2,stroke:#8E44AD,stroke-width:2px;
    classDef engine fill:#D5D8DC,stroke:#85929E,stroke-width:2px;
    classDef runner fill:#FFFFFF,stroke:#000000,stroke-width:1px,stroke-dasharray: 5 5;
```
