# iamcharankumar/api_test_framework architecture

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

- Interactive diagram: https://gitdiagram.com/iamcharankumar/api_test_framework
- Repository: https://github.com/iamcharankumar/api_test_framework

## Overview

##### Project Type and Purpose
- The project is a REST API test automation framework designed to facilitate regression testing. It runs via Maven and TestNG, supports parallel execution, and integrates with external reporting and notification systems (Report Portal and Discord). The README and file tree clearly show components dedicated to API requests, responses, configuration, logging, and external integrations.

##### File Structure
- Top-level Files:
- .gitignore, README.md, and pom.xml indicate version control, project documentation, and Maven build configuration respectively.
- src/main/java/io/backend:
- Contains the core framework code separated into logical packages:
- commons: Shared resources and helper methods (e.g., HTTP statuses, common REST resource definitions).
- constants: Contains API endpoint routes and constant values.
- entities: Definitions for different request and response objects for various API endpoints (including Discord, automationexercise, ifsc, Rick and Morty, and postal code related responses).
- exceptions: Custom exception classes handling specific error cases (e.g., DiscordException).
- services: Contains service classes segregated into:
▪ Discord: DiscordClient, DiscordController, DiscordHelper to manage messaging integration.
▪ rest: ApiClients, ApiControllers, ApiHelpers handling API interaction logic.
- utils: Utility classes for configuration loading, date manipulations, property handling, retry logic, and test utilities.
- resource: Configuration file (api.properties) which provides environmental or API-specific settings.
- src/test:
- Houses all integration and functional test cases using TestNG.
- Organized into multiple packages to run tests for different APIs (automationexercise, ifsc, reqres, rickandmorty, zippo) along with base classes, constants (TestGroups), listeners, and test data providers.
- Additional resources for logging and reportportal configuration (logback.xml, reportportal.properties) are provided.

##### Key Components
a. Test Runner & Execution Environment:
- A block representing the Maven/TestNG integration. This includes the trigger for tests via a Maven command or TestNG XML file.
- Use of TestNG parallelism and configurable thread pools.
b. Core Framework Modules:
- Commons (shared utilities and base classes).
- Constants (for API routes and keys).
- Entities (request and response models).
- Exceptions (custom error handlers).
- Services:
- Subdivide this into REST services (handling API requests/responses) and Discord services (handling messaging functionality).
- Utils (configuration, date, retry mechanisms, test utilities).
c. Testing Layer:
- Separate the “src/test” components by grouping the test classes, test data providers, and listeners.
- That the BaseTest and TestGroups manage the execution of various API tests.
d. External Integrations:
- Report Portal: Represented as an external system that receives test reports and logs (with configuration in reportportal.properties and Docker setup instructions noted in the README).
- Discord: Shown as an external chat/notification system that receives messages from the Discord service integration, using webhook tokens provided in the ApiConstants.
e. Configuration and Infrastructure:
- A block for configuration files (api.properties, reportportal.properties, logback.xml) which feed into both the framework’s utilities and the external integrations.
- The Maven build (pom.xml) and Docker configuration (docker-compose.yml for Report Portal) could be indicated as infrastructure and build pipeline artifacts.

##### Relationships and Data Flows
- Test Execution Flow: From the “Test Runner” (triggered by Maven command) to test classes (src/test), then invoking API interaction methods from the services.
- API Testing Flow: From REST test cases to the ApiClients/ApiControllers in the core services. This flow should indicate the sending of requests (using entities) and receiving responses.
- Exception Flow: Errors are captured and handled via the exceptions package.
- Utility Flow: Configuration values are loaded and provided via the utils layer.

##### Architectural Patterns or Design Principles
- Layered Architecture: The design separates utilities, core API services, entities, and tests, allowing for clear modular separation.
- Separation of Concerns: Different packages are dedicated to distinct responsibilities (e.g., API interactions vs. discord messaging).
- Test Driven Design: The test layer is rich with well-organized packages for various test scenarios, emphasizing reusability and modularity.
- External Integration: The design supports pluggable integrations for reporting (Report Portal) and notifications (Discord), highlighting extensibility points.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Build & Execution Layer
    subgraph "Build & Execution"
        A["Maven Build & Test Runner"]:::build
    end

    %% Test Layer
    subgraph "Test Layer"
        B["Test Cases (src/test/java/io/backend/api)"]:::test
        B2["Test Data Providers (src/test/java/io/backend/api/testdata)"]:::test
    end

    %% Core Framework Modules
    subgraph "Core Framework Modules"
        C["Commons"]:::core
        D["Constants"]:::core
        E["Entities"]:::core
        F["Exceptions"]:::core
        G["REST Services"]:::core
        H["Discord Services"]:::core
        I["Utilities"]:::core
    end

    %% External Integrations
    subgraph "External Integrations"
        M["Report Portal"]:::external
        N["Discord Notifications"]:::external
    end

    %% Configuration and Infrastructure
    subgraph "Configuration and Infrastructure"
        J["API Config (api.properties)"]:::config
        K["ReportPortal Config (reportportal.properties)"]:::config
        L["Logging Config (logback.xml)"]:::config
    end

    %% Connections
    A -->|"triggers"| B
    B -->|"suppliesData"| B2
    B -->|"executes_API_Call"| G
    B -->|"utilizes"| I
    B -->|"leverages"| E
    B -->|"references"| C
    G -->|"depends_on"| D
    G -->|"uses"| I
    G -->|"models"| E
    B -- "handles_errors" --> F
    H -->|"sends_notification"| N
    B -->|"triggers_notifications"| H
    B -->|"reports_results"| M
    I -->|"loads_config"| J
    I -->|"loads_config"| K
    I -->|"loads_config"| L

    %% Styling Classes
    classDef build fill:#D3D3D3,stroke:#000,stroke-width:2px;
    classDef test fill:#90EE90,stroke:#000,stroke-width:2px;
    classDef core fill:#ADD8E6,stroke:#000,stroke-width:2px;
    classDef external fill:#FFD580,stroke:#000,stroke-width:2px;
    classDef config fill:#FFB6C1,stroke:#000,stroke-width:2px;

    %% Click Events
    click A "https://github.com/iamcharankumar/api_test_framework/blob/master/pom.xml"
    click B "https://github.com/iamcharankumar/api_test_framework/tree/master/src/test/java/io/backend/api"
    click B2 "https://github.com/iamcharankumar/api_test_framework/tree/master/src/test/java/io/backend/api/testdata"
    click C "https://github.com/iamcharankumar/api_test_framework/tree/master/src/main/java/io/backend/commons"
    click D "https://github.com/iamcharankumar/api_test_framework/tree/master/src/main/java/io/backend/constants"
    click E "https://github.com/iamcharankumar/api_test_framework/tree/master/src/main/java/io/backend/entities"
    click F "https://github.com/iamcharankumar/api_test_framework/tree/master/src/main/java/io/backend/exceptions"
    click G "https://github.com/iamcharankumar/api_test_framework/tree/master/src/main/java/io/backend/services/rest"
    click H "https://github.com/iamcharankumar/api_test_framework/tree/master/src/main/java/io/backend/services/discord"
    click I "https://github.com/iamcharankumar/api_test_framework/tree/master/src/main/java/io/backend/utils"
    click J "https://github.com/iamcharankumar/api_test_framework/blob/master/src/main/java/resource/api.properties"
    click K "https://github.com/iamcharankumar/api_test_framework/blob/master/src/test/resources/reportportal.properties"
    click L "https://github.com/iamcharankumar/api_test_framework/blob/master/src/test/resources/logback.xml"
```
