# abhaybharti/playwright-framework-template architecture

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

- Interactive diagram: https://gitdiagram.com/abhaybharti/playwright-framework-template
- Repository: https://github.com/abhaybharti/playwright-framework-template

## Overview

##### Project Type and Purpose
- This is not a conventional application but a test automation framework/template using Playwright, Appium, and Artillery.
- Its primary purpose is to provide a comprehensive structure for writing, organizing, and running automated tests across multiple platforms (web, API, mobile, and load scenarios).
- The README highlights different types of tests (web, API, mobile, and load) along with detailed instructions for running tests and generating reports.

##### File Structure
- Top-level configuration and environment files (.env, config.ts, environments/*) indicate configurable environment management.
- The presence of multiple configuration files (e.g., playwright.config.ts, playwright.config.chrome.ts, and specific environment files) suggests flexible testing configurations.
- The src directory is organized into subfolders:
- globals – holds global setup/teardown routines and health checks.
- helper – modular helper functions categorized for API, web, and mobile interactions.
- utils – contains configuration specifics, reporting logic, constant definitions, and error handling.
- The tests directory is divided into subfolders (api, e2e, load, mobile, web) to keep the test scripts for different testing types separate. This clearly reflects a modular architectural approach with separation of concerns.
- Additional configuration files for linting (.eslintrc.js), formatting (.prettierrc), and CI/CD workflows (.github/workflows) indicate that quality and automation processes are integral to the project.

##### README for Additional Insights
- The README clarifies component responsibilities (e.g., what functions reside in src/helper vs. tests) and explains the architectural patterns and best practices (like isolate test cases, use of environment configurations, and integration with CI/CD pipelines).
- It outlines how tests should interface with helpers and utilities and mentions platforms like Azure for scalable execution.

a. Main Components:
- Test Runner and Orchestrator: The Playwright testing runner configured via playwright.config.ts and its variants.
- Global Setup/Teardown: Located in src/globals for initializing and cleaning up test environments.
- Helpers:
- API Helper: Handles HTTP communications (e.g., src/helper/api/apiHelper.ts).
- Web Helper: Manages browser interactions (e.g., src/helper/web/webHelper.ts).
- Mobile Helper: Supports mobile app testing (e.g., src/helper/terminal/SSHHelper.ts and mobile directories).
- Utility Services:
- Config utilities (src/utils/config/*) for environment and pipeline configurations.
- Reporting and logging utilities (src/utils/report/* and logs folder).
- Data persistence (src/utils/dataStore.js) to share data between tests.
- Test Suites:
- API, web, mobile, e2e, and load tests organized under the tests directory.
- CI/CD and Deployment Components:
- GitHub workflows and DockerFile provide the structure for CI integration and containerized execution.

b. Relationships and Interactions:
- Tests invoke functions provided by Helper modules to interact with the application under test or simulated environments.
- Global setup injects test-wide configurations, environment variables, and healthcheck routines that persist across the module executions.
- Utility components support configuration management, error handling, and reporting—interacting with helper functions, tests, and CI/CD pipelines.
- Continuous integration flows (GitHub workflows and Azure pipeline configs) trigger test executions and handle logging/trace reporting posts-execution.

c. Architectural Patterns and Design Principles:
- Modular Architecture: Separation between test files, helper functions, and utilities using clear directory boundaries.
- Layered Structure: Each layer (global configurations, helper libraries, test suites) has well-defined responsibilities.
- Configurability: Environment-specific configurations and dynamic test setups enable portability across different testing scenarios.
- Emphasis on reusability: Common functionalities, like API calls, browser actions, and logging, are encapsulated in helper modules.

d. Relevant Technologies, Frameworks, and Tools:
- Testing: Playwright (for web and API tests), Appium (for mobile testing), Artillery (for load testing).
- Code Quality: ESLint, Prettier.
- Environment: Dotenv for configurations.
- Reporting and Debugging: HTML reports, trace outputs, snapshot capture.
- CI/CD: GitHub Actions and Azure Pipelines integration.
- Scripting and Runtime: Node.js, with TypeScript support (using ts-node for direct execution if needed).

##### Elements
- Clear labels for each component (e.g., “Playwright Test Runner,” “API Helper Module,” “Global Setup/Teardown,” “Reporting Utility,” “CI/CD Integration”).
- How tests invoke helper functions.
- The flow from global configuration to test execution.
- Interaction between various helper modules and utility functions.
- Data flow from test execution to reporting/logging systems.
- Rectangles for primary modules (test runner, helpers, CI).

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% CI/CD Integration Layer
    subgraph "CI/CD Integration"
        CICD["CI/CD Integration Components"]:::ci
    end

    %% Test Runner Layer
    subgraph "Test Runner Layer"
        PT["Playwright Test Runner"]:::runner
        GST["Global Setup/Teardown"]:::runner
    end

    %% Helpers & Utilities Layer
    subgraph "Helpers & Utilities"
        APIH["API Helper Module"]:::helper
        WH["Web Helper Module"]:::helper
        MH["Mobile Helper Module"]:::helper
        CU["Config Utilities"]:::helper
        RU["Reporting Utility"]:::helper
        DPS["Data Persistence Utility"]:::helper
    end

    %% Test Suites Layer
    subgraph "Test Suites"
        API["API Tests"]:::tests
        E2E["End-to-End Tests"]:::tests
        MH2["Mobile Tests"]:::tests
        WT["Web Tests"]:::tests
        LT["Load Tests"]:::tests
    end

    %% Define Relationships
    CICD -->|"triggers"| PT
    PT -->|"initializes"| GST
    GST -->|"loadsConfigs"| CU
    PT -->|"executes"| API
    PT -->|"executes"| E2E
    PT -->|"executes"| MH2
    PT -->|"executes"| WT
    PT -->|"executes"| LT

    API -->|"calls"| APIH
    E2E -->|"calls"| APIH
    E2E -->|"calls"| WH
    WT -->|"calls"| WH
    MH2 -->|"calls"| MH

    API -->|"reportsTo"| RU
    E2E -->|"reportsTo"| RU
    WT -->|"reportsTo"| RU
    MH2 -->|"reportsTo"| RU
    LT -->|"reportsTo"| RU

    API -->|"storesData"| DPS
    E2E -->|"storesData"| DPS
    WT -->|"storesData"| DPS
    MH2 -->|"storesData"| DPS
    LT -->|"storesData"| DPS

    LT -->|"reads"| CU

    %% Legend subgraph
    subgraph "Legend"
        L1["Rectangle: Primary Modules"]
        L2["Cylinder: Data Stores/Config (symbolized through CU & DPS)"]
        L3["Arrow: Execution/Data Flow"]
    end

    %% Click Events
    click PT "https://github.com/abhaybharti/playwright-framework-template/blob/master//playwright.config.ts"
    click GST "https://github.com/abhaybharti/playwright-framework-template/blob/master//src/globals/global-setup.ts"
    click APIH "https://github.com/abhaybharti/playwright-framework-template/blob/master//src/helper/api/apiHelper.ts"
    click WH "https://github.com/abhaybharti/playwright-framework-template/blob/master//src/helper/web/webHelper.ts"
    click MH "https://github.com/abhaybharti/playwright-framework-template/blob/master//src/helper/terminal/SSHHelper.ts"
    click CU "https://github.com/abhaybharti/playwright-framework-template/tree/master//src/utils/config/"
    click RU "https://github.com/abhaybharti/playwright-framework-template/tree/master//src/utils/report/"
    click DPS "https://github.com/abhaybharti/playwright-framework-template/blob/master//src/utils/dataStore.js"
    click API "https://github.com/abhaybharti/playwright-framework-template/tree/master//tests/api/"
    click E2E "https://github.com/abhaybharti/playwright-framework-template/tree/master//tests/e2e/"
    click MH2 "https://github.com/abhaybharti/playwright-framework-template/tree/master//tests/mobile/"
    click WT "https://github.com/abhaybharti/playwright-framework-template/tree/master//tests/web/"
    click LT "https://github.com/abhaybharti/playwright-framework-template/tree/master//tests/load/"
    click CICD "https://github.com/abhaybharti/playwright-framework-template/tree/master//github/workflows/"

    %% Styles
    classDef ci fill:#f9c74f,stroke:#333,stroke-width:2px;
    classDef runner fill:#90be6d,stroke:#333,stroke-width:2px;
    classDef helper fill:#f9844a,stroke:#333,stroke-width:2px;
    classDef tests fill:#577590,stroke:#fff,stroke-width:2px,color:#fff;
    classDef legend fill:#eeeeee,stroke:#333,stroke-width:1px;
```
