# yogesh2511/codingtestapexsystemslabcorp architecture

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

- Interactive diagram: https://gitdiagram.com/yogesh2511/codingtestapexsystemslabcorp
- Repository: https://github.com/yogesh2511/codingtestapexsystemslabcorp

## Overview

##### Project type and purpose
- This is a QA Automation Framework for LabCorp’s Careers site. It’s both a UI test suite (Selenium WebDriver + Page Object Model) and an API test suite (REST-Assured), orchestrated via Cucumber BDD and TestNG, packaged with Maven.

##### File structure
- Top-level directories:
- src/main/java/api/clients, api/models, api/services → HTTP client code + domain objects for API tests
- src/main/java/pages → Page Object classes for UI tests
- src/main/java/stepdefinitions → Glue code binding Gherkin steps to actions
- src/main/java/hooks → Cucumber hooks for setup/teardown (UIHooks, APIHooks, ScenarioHooks)
- src/main/java/utilities → Shared helpers (DriverManager, Config, FileUtils, LoggerUtils, WaitUtils, ExtentManager, etc.)
- src/main/resources/features → Gherkin feature files (UI & API)
- src/main/resources/config.properties, runner/testng.xml → configuration files
- Build & run: pom.xml, Maven lifecycle, TestNG runner (TestNgRunner).

##### Key insights from README
- Tech stack: Java 17, Maven, Selenium, REST-Assured, Cucumber BDD, TestNG, ExtentReports.
- Design pattern: Page Object Model.
- Reporting: ExtentReports and Cucumber HTML.
- Custom logging and screenshot capture on failures.
- ScenarioContextManager shares state across steps.

##### Main components
A. **Feature Files** (Gherkin)
B. **Test Runner** (TestNgRunner + Cucumber)
C. **Step Definitions** (UISteps, ApiSteps)
D. **Hooks** (UIHooks, APIHooks, ScenarioHooks)
E. **Page Object Layer** (ApplicationPage, HomePage, CareersPage, JobDetailsPage, etc.)
F. **API Layer**
1. Clients & Models (RestClient, Address, Customer, Order, Payment, Shipping, Response, etc.)
2. Services (OrderService)
G. **Utilities**
- DriverManager → WebDriver lifecycle
- Config → load config.properties
- FileUtils → read/write JSON payloads
- LoggerUtils → custom logging to Application.log, Selenium.log
- WaitUtils, WebElementHelper, JavaScriptUtils
- ExtentManager, ReportHelperListener → report generation
H. **External Systems**
1. Browser (Chrome via WebDriverManager)
2. LabCorp Careers Web Application (UI under test)
3. LabCorp API endpoints
I. **Artifacts**
- HTML Reports (ExtentReports, Cucumber Reports)
- Logs (.log files)
- Screenshots on failure

##### Relationships & data flow
1. Runner loads Feature Files → Cucumber kicks off Scenarios
2. Hooks initialize context:
- UIHooks → starts WebDriver via DriverManager
- APIHooks → configures RestAssured base URI
3. Step Definitions execute:
- UI steps call methods on Page Objects → Page Objects use WebElementHelper, WaitUtils → WebDriver → Browser → UI under test
- API steps call Services → Services use RestClient → HTTP request/response to API endpoints → ScenarioContextManager stores response data
4. Utilities invoked throughout for config, logging, file I/O
5. On each step or failure, LoggerUtils writes logs; UI failures trigger screenshots
6. After scenario, ReportHelperListener and ExtentManager collect test results → generate HTML reports
7. Hooks teardown: close browser, clear context

##### Architectural patterns & design principles
- **Page Object Model** for UI abstraction
- **Service/Client** separation for API (models vs. service logic)
- **Cucumber BDD** to keep tests readable and maintainable
- **Hooks** to centralize setup/teardown
- **Utilities** to avoid duplication and handle cross-cutting concerns (logging, waits, config)

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Test Runner and Feature Files
    subgraph "Test Runner"
        TR[TestNgRunner]:::code
        TNG[TestNG Config]:::config
    end
    subgraph "Feature Files"
        FF[Feature Files]:::doc
    end
    TR -->|"loads"| FF
    TR -->|"uses"| TNG

    %% Hooks
    subgraph "Hooks"
        UIH[UIHooks]:::code
        APIH[APIHooks]:::code
        SCH[ScenarioHooks]:::code
        SCM[ScenarioContextManager]:::code
    end
    TR -->|"initializes"| UIH
    TR -->|"initializes"| APIH
    TR -->|"initializes"| SCH
    SCH -->|"manages state"| SCM

    %% Step Definitions
    subgraph "Step Definitions"
        UIS[UISteps]:::code
        APS[ApiSteps]:::code
    end
    UIH -->|"calls"| UIS
    APIH -->|"calls"| APS
    SCM -->|"shares context"| UIS
    SCM -->|"shares context"| APS

    %% UI Layer
    subgraph "UI Layer"
        BP[BasePage]:::code
        AP[ApplicationPage]:::code
        HP[HomePage]:::code
        CP[CareersPage]:::code
        JP[JobDetailsPage]:::code
        DM[DriverManager]:::util
        WE[WebElementHelper]:::util
        WT[WaitUtils]:::util
        JS[JavaScriptUtils]:::util
    end
    UIS -->|"calls"| BP
    UIS -->|"navigates"| AP
    UIS -->|"interacts"| HP
    UIS -->|"interacts"| CP
    UIS -->|"interacts"| JP
    BP -->|"uses"| WE
    BP -->|"uses"| WT
    BP -->|"uses"| JS
    UIH -->|"starts"| DM

    %% API Layer
    subgraph "API Layer"
        RC[RestClient]:::code
        AM[API Models]:::code
        OS[OrderService]:::code
    end
    APS -->|"calls"| OS
    OS -->|"uses"| RC
    RC -->|"handles"| AM
    APIH -->|"sets base URI"| RC

    %% Utilities
    subgraph "Utilities"
        CFG[Config]:::util
        FU[FileUtils]:::util
        LU[LoggerUtils]:::util
        EM[ExtentManager]:::util
        RHL[ReportHelperListener]:::util
        AU[AliasUtility]:::util
    end
    UIH -->|"reads config"| CFG
    APIH -->|"reads config"| CFG
    UIS -->|"logs via"| LU
    APS -->|"logs via"| LU
    FU -->|"provides payloads"| RC
    RHL -->|"collects results"| EM
    SCH -->|"invokes"| RHL

    %% External Systems
    subgraph "External Systems"
        BZ[Browser]:::external
        UIApp[LabCorp Careers UI]:::external
        APIApp[LabCorp API Endpoints]:::external
    end
    DM -->|"controls"| BZ
    BP -->|"drives"| BZ
    BZ -->|"renders"| UIApp
    RC -->|"HTTP calls"| APIApp

    %% Artifacts
    subgraph "Artifacts"
        HTML[HTML Reports]:::doc
        LOGS[Logs & Screenshots]:::doc
    end
    EM -->|"generates"| HTML
    LU -->|"writes"| LOGS
    SCH -->|"on failure"| LOGS

    %% Configuration & Payloads
    subgraph "Config & Payloads"
        CNF[config.properties]:::config
        JSON[JSON Payloads]:::doc
    end
    CFG -->|"loads"| CNF
    FU -->|"reads"| JSON

    %% Click Events
    click FF "https://github.com/yogesh2511/codingtestapexsystemslabcorp/tree/master/src/main/resources/features"
    click TR "https://github.com/yogesh2511/codingtestapexsystemslabcorp/blob/master/src/main/java/runner/TestNgRunner.java"
    click TNG "https://github.com/yogesh2511/codingtestapexsystemslabcorp/blob/master/src/main/resources/runner/testng.xml"
    click UIS "https://github.com/yogesh2511/codingtestapexsystemslabcorp/blob/master/src/main/java/stepdefinitions/UISteps.java"
    click APS "https://github.com/yogesh2511/codingtestapexsystemslabcorp/blob/master/src/main/java/stepdefinitions/ApiSteps.java"
    click UIH "https://github.com/yogesh2511/codingtestapexsystemslabcorp/blob/master/src/main/java/hooks/UIHooks.java"
    click APIH "https://github.com/yogesh2511/codingtestapexsystemslabcorp/blob/master/src/main/java/hooks/APIHooks.java"
    click SCH "https://github.com/yogesh2511/codingtestapexsystemslabcorp/blob/master/src/main/java/hooks/ScenarioHooks.java"
    click SCM "https://github.com/yogesh2511/codingtestapexsystemslabcorp/blob/master/src/main/java/hooks/ScenarioContextManager.java"
    click BP "https://github.com/yogesh2511/codingtestapexsystemslabcorp/blob/master/src/main/java/pages/BasePage.java"
    click AP "https://github.com/yogesh2511/codingtestapexsystemslabcorp/blob/master/src/main/java/pages/ApplicationPage.java"
    click HP "https://github.com/yogesh2511/codingtestapexsystemslabcorp/blob/master/src/main/java/pages/HomePage.java"
    click CP "https://github.com/yogesh2511/codingtestapexsystemslabcorp/blob/master/src/main/java/pages/CareersPage.java"
    click JP "https://github.com/yogesh2511/codingtestapexsystemslabcorp/blob/master/src/main/java/pages/JobDetailsPage.java"
    click RC "https://github.com/yogesh2511/codingtestapexsystemslabcorp/blob/master/src/main/java/api/models/RestClient.java"
    click OS "https://github.com/yogesh2511/codingtestapexsystemslabcorp/blob/master/src/main/java/api/services/OrderService.java"
    click DM "https://github.com/yogesh2511/codingtestapexsystemslabcorp/blob/master/src/main/java/utilities/DriverManager.java"
    click CFG "https://github.com/yogesh2511/codingtestapexsystemslabcorp/blob/master/src/main/java/utilities/Config.java"
    click FU "https://github.com/yogesh2511/codingtestapexsystemslabcorp/blob/master/src/main/java/utilities/FileUtils.java"
    click LU "https://github.com/yogesh2511/codingtestapexsystemslabcorp/blob/master/src/main/java/utilities/LoggerUtils.java"
    click WT "https://github.com/yogesh2511/codingtestapexsystemslabcorp/blob/master/src/main/java/utilities/WaitUtils.java"
    click WE "https://github.com/yogesh2511/codingtestapexsystemslabcorp/blob/master/src/main/java/utilities/WebElementHelper.java"
    click JS "https://github.com/yogesh2511/codingtestapexsystemslabcorp/blob/master/src/main/java/utilities/JavaScriptUtils.java"
    click EM "https://github.com/yogesh2511/codingtestapexsystemslabcorp/blob/master/src/main/java/utilities/ExtentManager.java"
    click RHL "https://github.com/yogesh2511/codingtestapexsystemslabcorp/blob/master/src/main/java/utilities/ReportHelperListener.java"
    click AU "https://github.com/yogesh2511/codingtestapexsystemslabcorp/blob/master/src/main/java/utilities/AliasUtility.java"
    click CNF "https://github.com/yogesh2511/codingtestapexsystemslabcorp/blob/master/src/main/resources/config.properties"
    click JSON "https://github.com/yogesh2511/codingtestapexsystemslabcorp/blob/master/src/main/resources/premium_order.json"

    %% Styles
    classDef code fill:#D0E6FF,stroke:#005B96,color:#000;
    classDef util fill:#FFF4CC,stroke:#CC9900,color:#000;
    classDef external fill:#D6EFD6,stroke:#2E8B57,color:#000;
    classDef doc fill:#E0E0E0,stroke:#666,color:#000;
    classDef config fill:#F2DFDF,stroke:#C0392B,color:#000;
```
