# deepika5reddy/playwright_ts_e2e_api architecture

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

- Interactive diagram: https://gitdiagram.com/deepika5reddy/playwright_ts_e2e_api
- Repository: https://github.com/deepika5reddy/playwright_ts_e2e_api

## Overview

##### Project type and purpose
- This is a test-automation framework in TypeScript built on Playwright.
- It supports two testing modalities: end-to-end (UI) tests against a web application and API tests against backend endpoints.
- It’s designed for CI/CD pipelines (Jenkinsfile, buildspec.yml) and environment-specific configurations.

##### File structure
- Top level
- env/ – holds .env.local and .env.prod for environment-specific variables
- page-object/ – Page Object Model classes (AbstractPage, LoginPage, ProductGrid)
- tests/
– api/ – API test suites (ApiTest.spec.ts)
– e2e/ – UI test suites (ValidateLogin, ValidateGrid, ValidateBook, ValidateScreenshot) + storageState, screenshots
- utils/ – helper functions (env loader, generic helpers)
- playwright.config.ts – global Playwright settings
- playwright.service.config.ts – service-specific configuration
- CI/CD files: Jenkinsfile, buildspec.yml
- Standard Node/TS files: package.json, tsconfig.json

##### Key insights from README
- Uses the Page Object Model (POM) for UI tests.
- Tests are invoked via Playwright CLI or npm scripts.
- Outputs HTML reports via Playwright’s reporter.
- Integrates into CI (Jenkins/AWS CodeBuild).

##### Main components
a. Configuration Layer
- env loader (utils/env.ts)
- playwright.config.ts & playwright.service.config.ts
b. Test Runner & Orchestration
- Playwright Test Runner (invoked via CLI or CI)
c. Test Suites
- E2E UI suite (tests/e2e)
- API suite (tests/api)
d. Page Object Model
- AbstractPage, LoginPage, ProductGrid (page-object/)
e. Utility Functions
- env.ts, helper.ts (utils/)
f. External Systems
- Browser engines (Chromium, Firefox, WebKit)
- Application Under Test (ecommerce playground)
- API endpoints
- CI/CD server (Jenkins/AWS CodeBuild)
- Test reporting UI (Playwright HTML report)

##### Relationships & interactions
- CI Server → triggers Playwright Test Runner
- Test Runner reads Config Layer → sets ENV variables → chooses target URLs & credentials
- Test Runner invokes E2E suite
- Each test uses POM classes to drive browser → interacts with Application Under Test
- Captures screenshots, storage state
- Test Runner invokes API suite
- Sends HTTP requests to API endpoints → validates responses
- Test Runner → writes test results → calls Reporter → HTML reports
- CI Server → archives reports, notifies stakeholders

##### Architectural patterns & principles
- Page Object Model (separation of UI locators & actions)
- Single Test Runner orchestrating multiple test modalities
- Environment-driven configuration for portability
- Modularity: clear separation of config, POM, tests, utils
- CI/CD integration for continuous validation

##### Technologies & frameworks
- Node.js + TypeScript
- Playwright Test Runner
- Page Object Model for UI interaction
- Jest-style specs (Playwright uses test() & expect())
- Jenkins/AWS CodeBuild for CI
- .env files & dotenv for config
- npm scripts for ease of use

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% CI/CD Server and Pipeline Definitions
    CI["CI/CD Server"]:::external
    subgraph "CI Pipeline Definitions"
        Jenkinsfile["Jenkinsfile"]:::config
        buildspec["buildspec.yml"]:::config
    end
    CI -->|"uses"| Jenkinsfile
    CI -->|"uses"| buildspec
    CI -->|"triggers"| Runner

    %% Test Runner & Orchestration
    Runner["Playwright Test Runner"]:::runner

    %% Configuration Layer
    subgraph "Configuration Layer"
        ENVLOCAL[".env.local"]:::config
        ENVPROD[".env.prod"]:::config
        envLoader["Env Loader\n(utils/env.ts)"]:::config
        pwConfig["playwright.config.ts"]:::config
        pwServiceConfig["playwright.service.config.ts"]:::config
    end
    Runner -->|"loads env loader"| envLoader
    envLoader -->|"reads"| ENVLOCAL
    envLoader -->|"reads"| ENVPROD
    Runner -->|"loads config"| pwConfig
    Runner -->|"loads service config"| pwServiceConfig

    %% Utilities
    subgraph "Utilities"
        EnvUtil["env.ts"]:::util
        HelperUtil["helper.ts"]:::util
    end
    Runner -->|"uses utilities"| EnvUtil
    Runner -->|"uses utilities"| HelperUtil

    %% Test Suites
    subgraph "Test Suites"
        E2ESuite["E2E UI Suite"]:::e2e
        APISuite["API Suite"]:::api

        subgraph "E2E UI Suite Components"
            LoginTest["ValidateLogin.spec.ts"]:::e2e
            GridTest["ValidateGrid.spec.ts"]:::e2e
            BookTest["ValidateBook.spec.ts"]:::e2e
            ScreenshotTest["ValidateScreenshot.spec.ts"]:::e2e
            StorageState["storageState.json"]:::e2e
            ScreenshotsFolder["screenshots"]:::e2e
        end
        E2ESuite --> LoginTest
        E2ESuite --> GridTest
        E2ESuite --> BookTest
        E2ESuite --> ScreenshotTest
        E2ESuite --> StorageState
        E2ESuite --> ScreenshotsFolder

        subgraph "API Suite Components"
            ApiTest["ApiTest.spec.ts"]:::api
        end
        APISuite --> ApiTest
    end
    Runner -->|"invokes"| E2ESuite
    Runner -->|"invokes"| APISuite

    %% Page Object Model
    subgraph "Page Object Model"
        AbstractPage["AbstractPage.ts"]:::pom
        LoginPage["loginPage.ts"]:::pom
        ProductGrid["ProductGrid.ts"]:::pom
    end
    E2ESuite -->|"uses POM classes"| AbstractPage
    E2ESuite --> LoginPage
    E2ESuite --> ProductGrid

    %% External Systems
    subgraph "External Systems"
        Browsers["Browser Engines\n(Chromium/Firefox/WebKit)"]:::external
        AUT["Application Under Test"]:::external
        APIEndpoints["API Endpoints"]:::external
        Reporter["HTML Report"]:::external
    end
    E2ESuite -->|"drives browser"| Browsers
    Browsers -->|"interacts with"| AUT
    APISuite -->|"sends HTTP requests to"| APIEndpoints
    Runner -->|"generates report"| Reporter
    Reporter -->|"archives & notifies"| CI

    %% Click Events
    click envLoader "https://github.com/deepika5reddy/playwright_ts_e2e_api/blob/main/utils/env.ts"
    click pwConfig "https://github.com/deepika5reddy/playwright_ts_e2e_api/blob/main/playwright.config.ts"
    click pwServiceConfig "https://github.com/deepika5reddy/playwright_ts_e2e_api/blob/main/playwright.service.config.ts"
    click ENVLOCAL "https://github.com/deepika5reddy/playwright_ts_e2e_api/blob/main/env/.env.local"
    click ENVPROD "https://github.com/deepika5reddy/playwright_ts_e2e_api/blob/main/env/.env.prod"
    click Jenkinsfile "https://github.com/deepika5reddy/playwright_ts_e2e_api/tree/main/Jenkinsfile"
    click buildspec "https://github.com/deepika5reddy/playwright_ts_e2e_api/blob/main/buildspec.yml"
    click LoginTest "https://github.com/deepika5reddy/playwright_ts_e2e_api/blob/main/tests/e2e/ValidateLogin.spec.ts"
    click GridTest "https://github.com/deepika5reddy/playwright_ts_e2e_api/blob/main/tests/e2e/ValidateGrid.spec.ts"
    click BookTest "https://github.com/deepika5reddy/playwright_ts_e2e_api/blob/main/tests/e2e/ValidateBook.spec.ts"
    click ScreenshotTest "https://github.com/deepika5reddy/playwright_ts_e2e_api/blob/main/tests/e2e/ValidateScreenshot.spec.ts"
    click StorageState "https://github.com/deepika5reddy/playwright_ts_e2e_api/blob/main/tests/e2e/storageState.json"
    click ScreenshotsFolder "https://github.com/deepika5reddy/playwright_ts_e2e_api/tree/main/tests/e2e/screenshots"
    click ApiTest "https://github.com/deepika5reddy/playwright_ts_e2e_api/blob/main/tests/api/ApiTest.spec.ts"
    click AbstractPage "https://github.com/deepika5reddy/playwright_ts_e2e_api/blob/main/page-object/AbstractPage.ts"
    click LoginPage "https://github.com/deepika5reddy/playwright_ts_e2e_api/blob/main/page-object/loginPage.ts"
    click ProductGrid "https://github.com/deepika5reddy/playwright_ts_e2e_api/blob/main/page-object/ProductGrid.ts"

    %% Styles
    classDef config fill:#6b7280,stroke:#374151,color:#fff;
    classDef runner fill:#3b82f6,stroke:#1e3a8a,color:#fff;
    classDef e2e fill:#10b981,stroke:#065f46,color:#fff;
    classDef api fill:#f97316,stroke:#9a3412,color:#fff;
    classDef pom fill:#8b5cf6,stroke:#5b21b6,color:#fff;
    classDef util fill:#facc15,stroke:#a16207,color:#000;
    classDef external fill:#60a5fa,stroke:#1e40af,color:#fff;
```
