# ashutoshti/clipboardhealth architecture

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

- Interactive diagram: https://gitdiagram.com/ashutoshti/clipboardhealth
- Repository: https://github.com/ashutoshti/clipboardhealth

## Overview

##### Project Type and Purpose
- This is a hybrid BDD Automation Testing framework built in Java using Cucumber (with Gherkin syntax) along with TestNG/JUnit.
- Its goal is to facilitate behavior-driven development (BDD) testing of web applications on multiple browsers (Chrome and Firefox) using a modular, dynamic Page Object Model (POM) approach.
- The framework is designed so that both technical and non-technical stakeholders (developers, testers, scrum masters, etc.) can view the automation flow and reports.

##### Analyzing the File Structure
- Top-Level Components:
- “src/main/java” – Contains the core framework classes:
▪ driver package: Includes DriverFactory (handles browser instantiation and configuration) and ConstantVariable (stores fixed configuration values).
▪ pages package: Contains Page Objects such as HomePage and TelevisionPage that encapsulate the UI elements and actions.
▪ Util package: Provides utility functions and configurations via classes like ElementUtil and ConfigReader.
- “src/test/java” – Contains the testing-specific implementations:
▪ parallel package: Hosts the ApplicationHooks (which execute pre-/post-test methods), step definition classes (HomePageSteps, TelevisionSteps) that bind the Gherkin feature files to Java code, and a customReportListener for generating reports.
▪ testrunner package: Contains MyTestRunner, the entry point to trigger the tests.
- “src/test/resources” – Contains supporting resources:
▪ config folder: Contains config.properties for environment-specific variables (like browser name).
▪ Executable_Driver: Holds executable files for browsers (chromedriver.exe, geckodriver.exe).
▪ Features: Contains the Gherkin feature files (“Home.feature“ and “Television.feature”) that describe test scenarios.

##### Key Components and Their Interactions
a. Driver Management:
- DriverFactory (in driver package) selects and initializes the correct browser driver based on configurations done via ConfigReader (from Util).
- This module ensures that the browsers (Chrome, Firefox) are properly set up with necessary properties (like maximizing the window) before tests run.
b. Page Object Layer:
- Each page (HomePage, TelevisionPage) encapsulates the web elements and actions. This isolates the UI logic from the test scripts.
c. Utility Layer:
- The ElementUtil class and methods are used across pages and steps for common interactions (clicks, typing, waits, etc.).
d. Test Execution:
- The Test Runner (MyTestRunner) triggers scenarios written in Gherkin (“Features” folder).
- ApplicationHooks (from the parallel package) initialize preconditions (e.g., setting up drivers) before executing step definitions.
- Step definition classes (HomePageSteps, TelevisionSteps) map Gherkin steps to methods in the page objects.
- Upon execution, a customReportListener generates Cucumber test reports displayed in the console.

##### Architectural Patterns and Design Principles
- The Page Object Model (POM) is clearly used for encapsulating UI interactions.
- Separation of Concerns (SoC) is applied by segregating driver configuration, page interactions, utilities, and test execution.
- BDD principles drive the structure by linking human-readable Gherkin scenarios with the underlying automation code.
- Modular design: Each package (driver, pages, Util, test/parallel, testrunner, and resources) has a well-defined responsibility.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% External Resources
    subgraph "External Resources"
        A["Gherkin Feature Files"]:::external
        M["Config File"]:::external
        N["Browser Driver Executables"]:::external
    end

    %% Test Execution Layer
    subgraph "Test Execution"
        B["MyTestRunner"]:::testLogic
        C["ApplicationHooks"]:::testLogic
        D["HomePageSteps"]:::testLogic
        E["TelevisionSteps"]:::testLogic
        L["CustomReportListener"]:::testLogic
    end

    %% Application Layer
    subgraph "Application Layer"
        F["HomePage"]:::pageObject
        G["TelevisionPage"]:::pageObject
    end

    %% Driver & Configuration Layer
    subgraph "Driver & Configuration"
        H["DriverFactory"]:::driver
        I["ConstantVariable"]:::driver
        J["ConfigReader"]:::driver
    end

    %% Utility Layer
    subgraph "Utilities"
        K["ElementUtil"]:::util
    end

    %% Relationships
    A -->|"triggers"| B
    B -->|"initiates"| C
    C -->|"triggers"| D
    C -->|"triggers"| E
    D -->|"uses"| F
    E -->|"uses"| G
    F -->|"utilizes"| K
    G -->|"utilizes"| K
    F -->|"manages"| H
    G -->|"manages"| H
    H -->|"uses"| I
    H -->|"reads"| J
    J -->|"configures"| M
    H -->|"uses"| N
    B -->|"generates"| L

    %% Click Events
    click A "https://github.com/ashutoshti/clipboardhealth/tree/master/src/test/resources/Features"
    click M "https://github.com/ashutoshti/clipboardhealth/blob/master/src/test/resources/config/config.properties"
    click N "https://github.com/ashutoshti/clipboardhealth/tree/master/src/test/resources/Executable_Driver"
    click B "https://github.com/ashutoshti/clipboardhealth/blob/master/src/test/java/testrunner/MyTestRunner.java"
    click C "https://github.com/ashutoshti/clipboardhealth/blob/master/src/test/java/parallel/ApplicationsHooks.java"
    click D "https://github.com/ashutoshti/clipboardhealth/blob/master/src/test/java/parallel/HomePageSteps.java"
    click E "https://github.com/ashutoshti/clipboardhealth/blob/master/src/test/java/parallel/TelevisionSteps.java"
    click L "https://github.com/ashutoshti/clipboardhealth/blob/master/src/test/java/parallel/customReportListener.java"
    click F "https://github.com/ashutoshti/clipboardhealth/blob/master/src/main/java/pages/HomePage.java"
    click G "https://github.com/ashutoshti/clipboardhealth/blob/master/src/main/java/pages/TelevisionPage.java"
    click H "https://github.com/ashutoshti/clipboardhealth/blob/master/src/main/java/driver/DriverFactory.java"
    click I "https://github.com/ashutoshti/clipboardhealth/blob/master/src/main/java/driver/ConstantVariable.java"
    click J "https://github.com/ashutoshti/clipboardhealth/blob/master/src/main/java/Util/ConfigReader.java"
    click K "https://github.com/ashutoshti/clipboardhealth/blob/master/src/main/java/Util/ElementUtil.java"

    %% Styles
    classDef external fill:#d3d3d3,stroke:#000,stroke-width:2px;
    classDef testLogic fill:#add8e6,stroke:#000,stroke-width:2px;
    classDef pageObject fill:#90ee90,stroke:#000,stroke-width:2px;
    classDef driver fill:#fffacd,stroke:#000,stroke-width:2px;
    classDef util fill:#ffa07a,stroke:#000,stroke-width:2px;
```
