# qaamitkumar/opencart architecture

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

- Interactive diagram: https://gitdiagram.com/qaamitkumar/opencart
- Repository: https://github.com/qaamitkumar/opencart

## Overview

##### Project Type and Purpose
- This is a Java-based automated testing framework built with Maven, TestNG, and Selenium.
- It implements data-driven and cross-browser testing against a web application using the Page Object Model (POM).
- It includes Docker-based Selenium Grid orchestration, ExtentReports/HTML reporting, and utilities for data handling and logging.

##### Key Components
a. Test Runner & CI Integration
- Maven + TestNG (configured via multiple XML suite files: master.xml, grouping.xml, grid-docker.xml, crossbrowsertesting.xml)
- Optional integration point: Jenkins or local run.bat to kick off `mvn test`
b. Test Code
- src/test/java/testCases: Test classes (TC001_AccountRegistrationTest, TC002_LoginTest, TC003_LoginDDT)
- src/test/java/pageObjects: POM classes (HomePage, LoginPage, AccountRegistrationPage, MyAccountPage, BasePage)
- src/test/java/testBase/BaseClass.java: Sets up WebDriver instances, reads config, initializes reporting, logging, screenshots
c. Utilities
- DataProviders.java and ExcelUtility.java: Read test data from testData/Opencart_LoginData.xlsx
- ExtentReportManager.java: Configures ExtentReports HTML output
- log4j2.xml: Logging configuration
d. Configuration & Data
- src/test/resources/config.properties: URLs, credentials, browser settings
- docker-compose.yaml: Defines Selenium Grid Hub and node containers for Chrome/Firefox/Edge
e. External Services & Artifacts
- Selenium Grid Hub + browser nodes (Docker)
- CrossBrowserTesting (via crossbrowsertesting.xml suite)
- test-output/ & reports/: TestNG and ExtentReports artifacts and screenshots

##### Relationships & Data Flow
1) CI/Local Runner → Maven → TestNG Engine
2) TestNG reads suite XML, loads config.properties, initializes BaseClass
3) BaseClass spins up WebDriver (local or remote via Selenium Grid/CrossBrowserTesting)
4) TestNG executes testCases → each test calls PageObjects → PageObjects issue WebDriver commands → browser nodes
5) Browser nodes run tests, return responses to WebDriver client
6) Utilities capture logs, screenshots on failure, feed ExtentReportManager
7) On completion, TestNG and ExtentReports generate HTML/XML in test-output/ and reports/

##### Architectural Patterns & Principles
- Page Object Model: Encapsulate page interactions in pageObjects classes
- Data-Driven Testing: Externalize test data in Excel via DataProviders
- Factory/Singleton for WebDriver in BaseClass
- Modular suite definitions for grouping tests, grid execution, cross-browser execution

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% CI & Runner
    subgraph "CI / Maven Runner"
        Maven["Maven (pom.xml)"]:::ci
        RunBat["run.bat"]:::ci
    end
    click Maven "https://github.com/qaamitkumar/opencart/blob/main/pom.xml"
    click RunBat "https://github.com/qaamitkumar/opencart/blob/main/run.bat"

    %% Test Suite Definitions
    subgraph "Test Suite Definitions" 
        MasterXML["master.xml"]:::suite
        GroupXML["grouping.xml"]:::suite
        GridDockerXML["grid-docker.xml"]:::suite
        CBTXML["crossbrowsertesting.xml"]:::suite
    end
    click MasterXML "https://github.com/qaamitkumar/opencart/blob/main/master.xml"
    click GroupXML "https://github.com/qaamitkumar/opencart/blob/main/grouping.xml"
    click GridDockerXML "https://github.com/qaamitkumar/opencart/blob/main/grid-docker.xml"
    click CBTXML "https://github.com/qaamitkumar/opencart/blob/main/crossbrowsertesting.xml"

    %% TestNG Engine
    TestNG["TestNG Engine"]:::engine

    %% Config & Data
    subgraph "Configuration & Data"
        ConfigProp["config.properties"]:::config
        DockerCompose["docker-compose.yaml"]:::infra
        ExcelFile["Opencart_LoginData.xlsx"]:::data
    end
    click ConfigProp "https://github.com/qaamitkumar/opencart/blob/main/src/test/resources/config.properties"
    click DockerCompose "https://github.com/qaamitkumar/opencart/blob/main/src/test/resources/docker-compose.yaml"
    click ExcelFile "https://github.com/qaamitkumar/opencart/blob/main/testData/Opencart_LoginData.xlsx"

    %% Test Base & WebDriver
    BaseClass["BaseClass (WebDriver Factory)"]:::base
    click BaseClass "https://github.com/qaamitkumar/opencart/blob/main/src/test/java/testBase/BaseClass.java"

    %% Test Cases
    subgraph "Test Cases"
        TC001["TC001_AccountRegistrationTest"]:::testcase
        TC002["TC002_LoginTest"]:::testcase
        TC003["TC003_LoginDDT"]:::testcase
    end
    click TC001 "https://github.com/qaamitkumar/opencart/blob/main/src/test/java/testCases/TC001_AccountRegistrationTest.java"
    click TC002 "https://github.com/qaamitkumar/opencart/blob/main/src/test/java/testCases/TC002_LoginTest.java"
    click TC003 "https://github.com/qaamitkumar/opencart/blob/main/src/test/java/testCases/TC003_LoginDDT.java"

    %% Page Objects
    subgraph "Page Objects (POM)"
        HomePage["HomePage"]:::pageobject
        LoginPage["LoginPage"]:::pageobject
        AccountRegPage["AccountRegistrationPage"]:::pageobject
        MyAccountPage["MyAccountPage"]:::pageobject
        BasePage["BasePage"]:::pageobject
    end
    click HomePage "https://github.com/qaamitkumar/opencart/blob/main/src/test/java/pageObjects/HomePage.java"
    click LoginPage "https://github.com/qaamitkumar/opencart/blob/main/src/test/java/pageObjects/LoginPage.java"
    click AccountRegPage "https://github.com/qaamitkumar/opencart/blob/main/src/test/java/pageObjects/AccountRegistrationPage.java"
    click MyAccountPage "https://github.com/qaamitkumar/opencart/blob/main/src/test/java/pageObjects/MyAccountPage.java"
    click BasePage "https://github.com/qaamitkumar/opencart/blob/main/src/test/java/pageObjects/BasePage.java"

    %% Utilities
    subgraph "Utilities"
        DataProviders["DataProviders"]:::util
        ExcelUtil["ExcelUtility"]:::util
        ExtentMgr["ExtentReportManager"]:::util
        LogConfig["log4j2.xml"]:::config
    end
    click DataProviders "https://github.com/qaamitkumar/opencart/blob/main/src/test/java/utilities/DataProviders.java"
    click ExcelUtil "https://github.com/qaamitkumar/opencart/blob/main/src/test/java/utilities/ExcelUtility.java"
    click ExtentMgr "https://github.com/qaamitkumar/opencart/blob/main/src/test/java/utilities/ExtentReportManager.java"
    click LogConfig "https://github.com/qaamitkumar/opencart/blob/main/src/test/resources/log4j2.xml"

    %% External Services & Grid
    subgraph "External Services"
        SeleniumGrid["Selenium Grid Hub"]:::external
        GridNodes["Browser Nodes"]:::external
        CrossBrowser["CrossBrowserTesting"]:::external
    end

    %% Reporting Artifacts
    subgraph "Reports & Output"
        TestOutput["test-output/"]:::report
        ExtentReportsDir["reports/"]:::report
    end
    click TestOutput "https://github.com/qaamitkumar/opencart/tree/main/test-output/"
    click ExtentReportsDir "https://github.com/qaamitkumar/opencart/tree/main/reports/"

    %% Flows
    Maven -->|"mvn test"| TestNG
    RunBat -->|"executes"| Maven

    TestNG -->|"reads"| MasterXML
    TestNG -->|"reads"| GroupXML
    TestNG -->|"reads"| GridDockerXML
    TestNG -->|"reads"| CBTXML
    TestNG -->|"loads"| ConfigProp
    TestNG -->|"initializes"| BaseClass

    ConfigProp --> BaseClass
    DockerCompose --> SeleniumGrid

    BaseClass -->|"createDriver()"| SeleniumGrid
    BaseClass -->|"createDriver()"| CrossBrowser

    SeleniumGrid --> GridNodes
    GridNodes -->|"runs tests"| BaseClass

    CrossBrowser -->|"remote driver"| BaseClass

    TestNG -->|"executes"| TC001
    TestNG -->|"executes"| TC002
    TestNG -->|"executes"| TC003

    TC001 -->|"use POM"| HomePage
    TC001 --> LoginPage
    TC001 --> AccountRegPage

    TC002 --> LoginPage
    TC002 --> MyAccountPage

    TC003 --> LoginPage
    TC003 --> MyAccountPage

    HomePage -->|"findElement()"| BaseClass
    LoginPage --> BaseClass
    AccountRegPage --> BaseClass
    MyAccountPage --> BaseClass
    BasePage --> BaseClass

    TC003 -->|"reads data"| DataProviders
    DataProviders --> ExcelFile
    ExcelUtil --> ExcelFile

    BaseClass -->|"capture logs/screenshots"| LogConfig
    BaseClass -->|"send to"| ExtentMgr
    ExtentMgr --> ExtentReportsDir

    TestNG -->|"output"| TestOutput

    %% Styles
    classDef ci fill:#f9f,stroke:#333
    classDef suite fill:#bbf,stroke:#333
    classDef engine fill:#fdd,stroke:#333
    classDef base fill:#dfd,stroke:#333
    classDef testcase fill:#ffd,stroke:#333
    classDef pageobject fill:#ddf,stroke:#333
    classDef util fill:#dff,stroke:#333
    classDef config fill:#fed,stroke:#333
    classDef data fill:#fcf,stroke:#333
    classDef infra fill:#eee,stroke:#333
    classDef external fill:#cfc,stroke:#333
    classDef report fill:#fdd,stroke:#333
```
