# dangepalash2/taskcarelon architecture

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

- Interactive diagram: https://gitdiagram.com/dangepalash2/taskcarelon
- Repository: https://github.com/dangepalash2/taskcarelon

## Overview

##### Main components
- Test Runner (WebdriverIO): This is the core orchestrator (configured by wdio.conf.ts) that triggers test execution.
- API Testing Module: Represented by the “apiClient” folder, it includes various API wrappers (e.g., BasketAPI.ts, CheckoutAPI.ts) that use Superagent to send HTTP requests.
- UI Testing Module: This component incorporates the “pageObjects” folder and files under “src” (e2e test scripts, e.g., ui.e2e.ts) which interact with the user interface.
- Reporting Subsystem: This comprises the Allure reporting files and directories (allure-report, allure-results) including plugins, generated data files, and the reporting server (launched with "npm run allure").
- Utilities and Configuration: Include helper functions (helpers.ts), configuration files (tsconfig.json, wdio.conf.ts), and the package.json that manages dependencies and scripts.

##### Relationships and interactions
- The Test Runner (WDIO) initiates both UI and API tests.
- UI tests use the Page Object Model (from pageObjects) to abstract browser interactions, execute test flows, and capture screenshots upon failure.
- API tests use the client wrappers (in apiClient) to issue HTTP requests to the Juice Shop backend and validate responses.
- Both test types generate logs and result files that are processed by the Allure reporting integration.
- The system has an external dependency on a running Juice Shop instance (local setup per the instructions in the README).

##### Architectural patterns and design principles
- Separation of Concerns: UI tests, API tests, and reporting functionalities are clearly separated into different modules and folders.
- Page Object Model: The UI testing component employs POM (in pageObjects) to encapsulate browser interactions.
- Modular API Clients: Different API endpoints are encapsulated in separate files, providing an organized and maintainable test code structure.
- Reporting and Logging: Allure’s report-generation workflow illustrates an important pattern of capturing test results and converting them into readable reports.

##### Relevant technologies and frameworks
- WebdriverIO (WDIO) for test orchestration.
- Superagent (for API communications) and Chai (for assertions).
- Allure for test reporting.
- TypeScript as the primary programming language (as seen from .ts file extensions and tsconfig.json).

- “Test Runner (WebdriverIO)” at the center.
- Branch out to “UI Tests” and “API Tests”.
- Under “UI Tests”, include a component for “Page Objects” and “Screenshot Capture Utility”.
- Under “API Tests”, include individual API client modules (e.g., Basket, Checkout, etc.).
- Off to the side, create a “Reporting” component showing Allure’s reporting process (with “allure-results” feeding into an “Allure Report Generator” which outputs a viewable report).
- How the Test Runner dispatches tests.
- Data flow from tests to the reporting engine.
- Communication between test components and the Juice Shop application.
- Test execution modules (e.g., using rectangles for tests).
- Reporting/output components.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Main Components
    TR["Test Runner (WebdriverIO)"] 
    E["Juice Shop Application"]

    %% UI Tests Subgraph
    subgraph "UI Tests"
        UTS["UI Test Scripts (src/ui.e2e.ts)"]
        PO["Page Objects (pageObjects)"]
        SSC["Screenshot Capture Utility"]
    end

    %% API Tests Subgraph
    subgraph "API Tests"
        ATS["API Test Scripts (src/api.e2e.ts)"]
        AC["API Clients (apiClient)"]
    end

    %% Reporting Subgraph
    subgraph "Reporting"
        AR["Allure Results (allure-results)"]
        AG["Allure Report Generator"]
        ARV["Allure Report View (allure-report)"]
    end

    %% Utilities and Configuration Subgraph
    subgraph "Utilities and Configuration"
        H["Helpers (helpers.ts)"]
        T["Tsconfig (tsconfig.json)"]
        P["Package.json (package.json)"]
    end

    %% Relationships
    TR --> UTS
    TR --> ATS
    UTS --> PO
    UTS --> SSC
    ATS --> AC

    %% Both UI and API tests forward logs/results to Reporting
    UTS --> AR
    AC --> AR
    AR --> AG
    AG --> ARV

    %% Interaction with the external Juice Shop
    PO -->|"UI_interaction"| E
    AC -->|"API_calls"| E

    %% Utilities support Test Runner
    H -.-> TR
    T -.-> TR
    P -.-> TR

    %% Click Events
    click TR "https://github.com/dangepalash2/taskcarelon/blob/main/wdio.conf.ts"
    click UTS "https://github.com/dangepalash2/taskcarelon/blob/main/src/ui.e2e.ts"
    click PO "https://github.com/dangepalash2/taskcarelon/tree/main/pageObjects"
    click ATS "https://github.com/dangepalash2/taskcarelon/blob/main/src/api.e2e.ts"
    click AC "https://github.com/dangepalash2/taskcarelon/tree/main/apiClient"
    click AR "https://github.com/dangepalash2/taskcarelon/tree/main/allure-results"
    click ARV "https://github.com/dangepalash2/taskcarelon/tree/main/allure-report"
    click H "https://github.com/dangepalash2/taskcarelon/blob/main/helpers.ts"
    click T "https://github.com/dangepalash2/taskcarelon/blob/main/tsconfig.json"
    click P "https://github.com/dangepalash2/taskcarelon/blob/main/package.json"

    %% Styles
    classDef test fill:#f9e79f,stroke:#333,stroke-width:2px;
    classDef ui fill:#aed6f1,stroke:#333,stroke-width:2px;
    classDef api fill:#a3e4d7,stroke:#333,stroke-width:2px;
    classDef reporting fill:#f5b7b1,stroke:#333,stroke-width:2px;
    classDef utils fill:#d2b4de,stroke:#333,stroke-width:2px;
    classDef external fill:#b2bec3,stroke:#333,stroke-width:2px;

    class TR test;
    class UTS,PO,SSC ui;
    class ATS,AC api;
    class AR,AG,ARV reporting;
    class H,T,P utils;
    class E external;
```
