# svsatish/bdd-service-automation architecture

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

- Interactive diagram: https://gitdiagram.com/svsatish/bdd-service-automation
- Repository: https://github.com/svsatish/bdd-service-automation

## Overview

##### Project Type and Purpose
- This is a BDD Service Automation Framework for testing the Petstore Swagger API.
- It is not a typical full-stack application, but a test-automation tool structured around Cucumber, TestNG, and REST-Assured.

A. Feature Layer
- Gherkin feature files (`.feature`) under src/test/resources/features
B. Glue Layer (Step Definitions)
- Cucumber step definition classes in `com.example.api.stepdefinitions`
C. Model Layer
- POJO request/response classes in `com.example.api.models.user`
D. Service/Utility Layer
- RestUtil: wraps HTTP calls (REST-Assured)
- ConfigManager (Singleton): loads `dev.properties`/`qa.properties`
- ReportGenerator: produces custom HTML/JSON reports
E. Test Runner
- TestRunner extends `AbstractTestNGCucumberTests`, configured via `@CucumberOptions` and `testng.xml`
F. External System
- Petstore Swagger API (`https://petstore.swagger.io/v2`)
G. Build & Reporting
- Maven (`pom.xml`) orchestrates compile/test phases.
- Cucumber HTML/JSON reports under `reports/`

##### Architectural Patterns & Design Principles
- Singleton Pattern: `ConfigManager`
- Builder Pattern (POJO payloads via Lombok’s @Builder)
- Factory/Strategy Patterns (for generating dynamic test data or assertion strategies)
- Template Method Pattern: `AbstractTestNGCucumberTests` parent logic
- Separation of Concerns:
- Feature files vs. step code vs. utilities vs. models vs. runner
- DRY: shared methods in RestUtil, ConfigManager, ReportGenerator

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Feature Layer
    Feature["Feature Files:\ncreate_user.feature"]:::cucumber
    click Feature "https://github.com/svsatish/bdd-service-automation/blob/main/src/test/resources/features/create_user.feature"

    %% Test Runner & Engine
    Runner["TestRunner\n(AbstractTestNGCucumberTests)\nTemplate Method"]:::cucumber
    click Runner "https://github.com/svsatish/bdd-service-automation/blob/main/src/test/java/com/example/api/testrunner/TestRunner.java"
    click Runner "https://github.com/svsatish/bdd-service-automation/blob/main/testng.xml"

    %% Glue Layer
    Step["Step Definitions\n(CreateUserSteps)"]:::cucumber
    click Step "https://github.com/svsatish/bdd-service-automation/blob/main/src/test/java/com/example/api/stepdefinitions/CreateUserSteps.java"

    %% Service/Utility Layer
    subgraph Utils["Service/Utility Layer"]
        Config["ConfigManager\n(Singleton)"]:::utils
        click Config "https://github.com/svsatish/bdd-service-automation/blob/main/src/test/java/com/example/api/utils/ConfigManager.java"
        Rest["RestUtil\n(REST-Assured)"]:::utils
        click Rest "https://github.com/svsatish/bdd-service-automation/blob/main/src/test/java/com/example/api/utils/RestUtil.java"
        RG["ReportGenerator"]:::build
        click RG "https://github.com/svsatish/bdd-service-automation/blob/main/src/test/java/com/example/api/utils/ReportGenerator.java"
    end

    %% Environment Config
    subgraph Env["Environment Properties"]
        Dev["dev.properties"]:::build
        click Dev "https://github.com/svsatish/bdd-service-automation/blob/main/src/test/resources/config/dev.properties"
        QA["qa.properties"]:::build
        click QA "https://github.com/svsatish/bdd-service-automation/blob/main/src/test/resources/config/qa.properties"
    end

    %% External API
    API["Petstore Swagger API\n(https://petstore.swagger.io/v2)"]:::external

    %% Model Layer
    POJO["POJO Models\n(UserRequest)\nBuilder Pattern"]:::model
    click POJO "https://github.com/svsatish/bdd-service-automation/blob/main/src/test/java/com/example/api/models/user/UserRequest.java"

    %% Build & Reporting
    Maven["Maven\n(pom.xml)"]:::build
    click Maven "https://github.com/svsatish/bdd-service-automation/blob/main/pom.xml"
    Reports["reports/\n(HTML/JSON)"]:::build
    click Reports "https://github.com/svsatish/bdd-service-automation/tree/main/reports/"

    %% Flow & Dependencies
    Maven --> Runner
    Feature -->|"parse scenarios"| Runner
    Runner -->|"glue"| Step
    Step -->|"invoke"| Rest
    Rest -->|"depend on"| Config
    Config --> Dev
    Config --> QA
    Rest -->|"HTTP calls"| API
    API -->|"returns JSON"| POJO
    POJO -->|"used in assertions"| Step
    Step -->|"results to"| RG
    RG -->|"writes to"| Reports

    %% Styles
    classDef cucumber fill:#add8e6,stroke:#333,stroke-width:1px;
    classDef utils fill:#98fb98,stroke:#333,stroke-width:1px;
    classDef external fill:#ffa500,stroke:#333,stroke-width:1px;
    classDef build fill:#d3d3d3,stroke:#333,stroke-width:1px;
    classDef model fill:#f0e68c,stroke:#333,stroke-width:1px;
```
