# farhaanshareef/api-automation-rest-assured architecture

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

- Interactive diagram: https://gitdiagram.com/farhaanshareef/api-automation-rest-assured
- Repository: https://github.com/farhaanshareef/api-automation-rest-assured

## Overview

##### Project Type and Purpose
- This is an API-automation test framework (not a user-facing app).
- Purpose: execute CRUD API tests against a remote “User” service and generate HTML reports.

##### File Structure
- Top-level artifacts:
– pom.xml (Maven config/dependencies)
– testng.xml (TestNG suite definition)
– src/main/java/utils/ConfigReader.java (utility to read config.properties)
– src/main/resources/config.properties (base URL, credentials, etc.)
– src/test/java/tests (all TestNG test classes)
– reports/ (stores Extent Reports HTML output)
- Pattern: clear separation of Utilities, Test Definitions, Configuration, and Reporting.

##### README Insights
- Confirms technologies: Java, Rest Assured, TestNG, Extent Reports, Maven.
- Describes test cases (Create, Update, Patch, Delete, Get users).
- Build & run instructions (mvn install / mvn test → produce reports).

##### Main Components
a. Test Runner Layer
– TestNG engine (driven by testng.xml)
– Maven Surefire / Failsafe plugin (invokes TestNG on mvn test)
b. Test Code Layer
– Test Classes (TestCreateUser, TestUpdateUser, etc.)
– BaseTest (shared setup/teardown)
– Utils.ConfigReader (reads config.properties)
c. REST-Client Layer
– Rest Assured library (constructs HTTP requests, deserializes responses)
d. External System
– API Under Test (remote “User” service)
e. Reporting Layer
– Extent Reports (listens to TestNG events, generates HTML files under reports/)
f. Build & Dependency Management
– Maven (pom.xml defines dependencies for TestNG, Rest Assured, Extent Reports)

##### Architectural Patterns and Principles
- Layered Separation: Build/CI (Maven), Execution (TestNG), Utilities, REST client, Reporting.
- Single-source Configuration: config.properties drives all environment settings.
- Reusability: BaseTest and ConfigReader reduce duplication across tests.

##### Technologies & Frameworks to Call Out
- Java 11+
- Rest Assured (io.restassured)
- TestNG (org.testng)
- Extent Reports (com.aventstack.extentreports)
- Maven (pom.xml)

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Build & CI Layer
    subgraph "Build & CI"
        Maven["Maven Build & Dependency Management\n(pom.xml)"]:::build
    end

    %% Test Execution Layer
    subgraph "Test Execution"
        TestNGEngine["TestNG Engine\n(testng.xml)"]:::execution
        subgraph "Test Classes"
            TCU["TestCreateUser"]:::execution
            TDU["TestDeleteUser"]:::execution
            TGU["TestGetUser"]:::execution
            TPU["TestPatchUser"]:::execution
            TUU["TestUpdateUser"]:::execution
        end
        BaseTest["BaseTest\n(setup/teardown)"]:::execution
    end

    %% Utilities Layer
    subgraph "Utilities"
        ConfigReader["ConfigReader Utility"]:::utils
        ConfigProps["config.properties"]:::utils
    end

    %% REST-Client Layer
    RestAssured["Rest Assured Library"]:::restclient

    %% External System
    UserAPI["User Service API"]:::external

    %% Reporting Layer
    subgraph "Reporting"
        ExtentReports["Extent Reports Engine"]:::reporting
        Reports["HTML Reports\n(reports/*.html)"]:::reporting
    end

    %% Documentation
    subgraph "Documentation"
        README["README.md"]:::docs
    end

    %% Connections
    Maven -->|"invokes mvn test"| TestNGEngine
    TestNGEngine -->|"loads suite"| TCU
    TestNGEngine --> TDU
    TestNGEngine --> TGU
    TestNGEngine --> TPU
    TestNGEngine --> TUU

    TCU -->|"extends"| BaseTest
    TDU --> BaseTest
    TGU --> BaseTest
    TPU --> BaseTest
    TUU --> BaseTest

    TCU -->|"reads config"| ConfigReader
    TDU --> ConfigReader
    TGU --> ConfigReader
    TPU --> ConfigReader
    TUU --> ConfigReader

    ConfigReader -->|"loads properties"| ConfigProps

    TCU -->|"HTTP GET/POST"| RestAssured
    TDU --> RestAssured
    TGU --> RestAssured
    TPU --> RestAssured
    TUU --> RestAssured

    RestAssured -->|"sends request"| UserAPI
    UserAPI -->|"returns response"| RestAssured

    TestNGEngine -->|"TestNG events"| ExtentReports
    ExtentReports -->|"generates HTML"| Reports

    README --> Maven

    %% Click Events
    click Maven "https://github.com/farhaanshareef/api-automation-rest-assured/blob/main/pom.xml"
    click TestNGEngine "https://github.com/farhaanshareef/api-automation-rest-assured/blob/main/testng.xml"
    click TCU "https://github.com/farhaanshareef/api-automation-rest-assured/blob/main/src/test/java/tests/TestCreateUser.java"
    click TDU "https://github.com/farhaanshareef/api-automation-rest-assured/blob/main/src/test/java/tests/TestDeleteUser.java"
    click TGU "https://github.com/farhaanshareef/api-automation-rest-assured/blob/main/src/test/java/tests/TestGetUser.java"
    click TPU "https://github.com/farhaanshareef/api-automation-rest-assured/blob/main/src/test/java/tests/TestPatchUser.java"
    click TUU "https://github.com/farhaanshareef/api-automation-rest-assured/blob/main/src/test/java/tests/TestUpdateUser.java"
    click BaseTest "https://github.com/farhaanshareef/api-automation-rest-assured/blob/main/src/test/java/tests/BaseTest.java"
    click ConfigReader "https://github.com/farhaanshareef/api-automation-rest-assured/blob/main/src/main/java/utils/ConfigReader.java"
    click ConfigProps "https://github.com/farhaanshareef/api-automation-rest-assured/blob/main/src/main/resources/config.properties"
    click Reports "https://github.com/farhaanshareef/api-automation-rest-assured/tree/main/reports/"
    click README "https://github.com/farhaanshareef/api-automation-rest-assured/blob/main/readme.md"

    %% Styles
    classDef build fill:#bbbbbb,stroke:#333,stroke-width:1px
    classDef execution fill:#ADD8E6,stroke:#333,stroke-width:1px
    classDef utils fill:#98FB98,stroke:#333,stroke-width:1px
    classDef restclient fill:#FFD700,stroke:#333,stroke-width:1px
    classDef external fill:#FFA500,stroke:#333,stroke-width:1px
    classDef reporting fill:#DDA0DD,stroke:#333,stroke-width:1px
    classDef docs fill:#EEEEEE,stroke:#333,stroke-width:1px
```
