# sas5999/enterprise_api_framework-2 architecture

> Architecture diagram of the GitHub repository sas5999/enterprise_api_framework-2, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-05-15). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/sas5999/enterprise_api_framework-2
- Repository: https://github.com/sas5999/enterprise_api_framework-2

## Overview

1. **Repository purpose and boundary**
   - This is a **Python pytest-based API test automation framework**, not an application backend.
   - The repo’s main boundary is between the **test harness** and an **external target API** (for example `reqres.in` by default). The framework orchestrates requests, assertions, logging, and reporting around that external system.

2. **Top-level architecture is layered**
   - The code is organized into four practical layers:
     - **Foundation:** `config/`, `utils/`, `schemas/`, `data/`
     - **API layer:** `api/`
     - **Action layer:** `actions/`
     - **Test layer:** `tests/`
   - The dependency direction is one-way downward: tests call actions, actions call the API client, and lower layers use foundation utilities.

3. **Test layer: suite organization and execution**
   - `tests/` contains the actual pytest suites, grouped by concern:
     - `tests/smoke/` for fast commit/PR gates
     - `tests/users/` for user CRUD-style coverage
     - `tests/auth/` for login/register coverage
   - Tests are marker-driven (`smoke`, `positive`, `negative`, `schema`, `performance`, `regression`, `wip`) so CI can select subsets without changing code.

4. **Action layer: business-level operations**
   - `actions/auth_actions.py` and `actions/user_actions.py` are the main abstraction for tests.
   - These classes represent **resource-level business flows** such as “get user”, “create user”, or “authenticate”, instead of raw HTTP calls.
   - This layer is the main boundary that keeps tests readable and shields them from endpoint and request details.

5. **API layer: transport and endpoint definition**
   - `api/client.py` is the HTTP transport layer: it likely handles request execution, retries, pooling, masking, metrics, and fluent response wrapping as described in the README.
   - `api/endpoints.py` centralizes path construction, so endpoint strings are defined once and reused by all actions.
   - This separation means URL structure changes are isolated from tests.

6. **Foundation layer: configuration, contracts, and utilities**
   - `config/settings.py` provides environment-driven settings such as base URL, timeouts, retries, and SLA thresholds.
   - `schemas/user_schemas.py` holds JSON schema contracts used to detect API response drift.
   - `utils/logger.py` and `utils/helpers.py` provide cross-cutting support such as logging, retry/assertion helpers, and likely test instrumentation.

7. **Test data generation**
   - `data/factories/user_factory.py` generates payloads for positive and negative cases.
   - This factory-based approach supports realistic and boundary-oriented test data without hardcoding payloads in the tests.
   - It is a key input source into the action layer when creating or validating users.

8. **Request/response flow through the system**
   - A typical flow is: **pytest test → action method → API client → external API → response wrapper/assertions → schema validation/logging/reporting**.
   - Tests generally do not speak directly to the client; they invoke actions and then use assertion helpers or schema validators on the returned response object.

9. **Shared test fixtures and session behavior**
   - `conftest.py` is the central pytest integration point for fixtures, metrics collection, and reporting enrichment.
   - This is where action instances and shared session state are likely injected into tests.
   - Session-level behavior such as aggregated request metrics and reporting hooks is coordinated here rather than in individual tests.

10. **Environment and configuration model**
    - Configuration is externalized via `.env.example` and loaded through `config/settings.py`.
    - The framework supports multiple environments (`dev`, `staging`, `uat`, `prod`) with environment-specific base URLs and runtime knobs like timeout, retries, and SLA budgets.
    - This makes the same test suite portable across deployment targets.

11. **CI/CD and developer workflow**
    - `.github/workflows/ci.yml` defines a staged pipeline: **quality checks → smoke tests → full suite → reporting**.
    - `.pre-commit-config.yaml` enforces local hygiene before code reaches CI.
    - The architecture is designed so smoke tests act as an early gate, while broader marker groups run later.

12. **External integrations and observability**
    - The framework is built to integrate with **Allure** for report generation and likely stores request metrics for session summaries.
    - Logging is designed to redact sensitive fields, which matters because credentials or bearer tokens may be injected into requests via config.
    - These observability features are cross-cutting concerns that sit beside the test flow rather than inside individual tests.

13. **What to draw in an architecture diagram**
    - Show the **external API under test** as the system boundary.
    - Inside the repo, show four stacked layers with arrows:
      - `tests/` → `actions/` → `api/` → external API
      - `config/`, `utils/`, `schemas/`, `data/` feeding into actions, API client, and tests as shared foundation
    - Add side channels for **logging/metrics/reporting** and **CI/pre-commit** as orchestration and observability paths.

Main entry points: [`api/client.py`](https://github.com/sas5999/enterprise_api_framework-2/blob/main/api/client.py) (API Client), [`.github/workflows/ci.yml`](https://github.com/sas5999/enterprise_api_framework-2/blob/main/.github/workflows/ci.yml) (CI Workflow), [`actions/auth_actions.py`](https://github.com/sas5999/enterprise_api_framework-2/blob/main/actions/auth_actions.py) (Auth Actions), [`actions/user_actions.py`](https://github.com/sas5999/enterprise_api_framework-2/blob/main/actions/user_actions.py) (User Actions)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_foundation["Foundation"]
  node_config_settings["Settings<br/>env config<br/>[settings.py]"]
  node_logger["Logger<br/>logging<br/>[logger.py]"]
  node_helpers["Helpers<br/>assertion utils<br/>[helpers.py]"]
  node_user_schema["User Schema<br/>contract<br/>[user_schemas.py]"]
  node_user_factory["User Factory<br/>test data<br/>[user_factory.py]"]
end

subgraph group_api["API Layer"]
  node_endpoints["Endpoints<br/>route map<br/>[endpoints.py]"]
  node_client["API Client<br/>http transport<br/>[client.py]"]
end

subgraph group_actions["Action Layer"]
  node_auth_actions["Auth Actions<br/>resource flow<br/>[auth_actions.py]"]
  node_user_actions["User Actions<br/>resource flow<br/>[user_actions.py]"]
end

subgraph group_tests["Test Layer"]
  node_smoke_tests["Smoke Suite<br/>pytest suite<br/>[test_smoke.py]"]
  node_auth_tests["Auth Suite<br/>pytest suite<br/>[test_auth.py]"]
  node_user_tests["Users Suite<br/>pytest suite<br/>[test_users.py]"]
end

subgraph group_orchestration["Orchestration"]
  node_conftest["Pytest Fixtures<br/>pytest integration<br/>[conftest.py]"]
  node_ci_workflow["CI Workflow<br/>pipeline<br/>[ci.yml]"]
  node_precommit["Pre-commit<br/>local gate"]
end

node_external_api[("External API<br/>target system")]

node_smoke_tests -->|"calls"| node_auth_actions
node_auth_tests -->|"calls"| node_auth_actions
node_user_tests -->|"calls"| node_user_actions
node_auth_actions -->|"uses"| node_client
node_user_actions -->|"uses"| node_client
node_client -->|"resolves"| node_endpoints
node_client -->|"requests"| node_external_api
node_config_settings -->|"configures"| node_client
node_config_settings -->|"configures"| node_auth_actions
node_config_settings -->|"configures"| node_user_actions
node_logger -->|"observes"| node_client
node_helpers -->|"supports"| node_auth_actions
node_helpers -->|"supports"| node_user_actions
node_user_schema -->|"validates"| node_user_tests
node_user_factory -->|"feeds"| node_user_actions
node_conftest -->|"injects"| node_smoke_tests
node_conftest -->|"injects"| node_auth_tests
node_conftest -->|"injects"| node_user_tests
node_ci_workflow -->|"mirrors"| node_precommit
node_ci_workflow -->|"runs"| node_smoke_tests
node_ci_workflow -->|"runs"| node_auth_tests
node_ci_workflow -->|"runs"| node_user_tests
node_ci_workflow -->|"executes through"| node_conftest

click node_config_settings "https://github.com/sas5999/enterprise_api_framework-2/blob/main/config/settings.py"
click node_logger "https://github.com/sas5999/enterprise_api_framework-2/blob/main/utils/logger.py"
click node_helpers "https://github.com/sas5999/enterprise_api_framework-2/blob/main/utils/helpers.py"
click node_user_schema "https://github.com/sas5999/enterprise_api_framework-2/blob/main/schemas/user_schemas.py"
click node_user_factory "https://github.com/sas5999/enterprise_api_framework-2/blob/main/data/factories/user_factory.py"
click node_endpoints "https://github.com/sas5999/enterprise_api_framework-2/blob/main/api/endpoints.py"
click node_client "https://github.com/sas5999/enterprise_api_framework-2/blob/main/api/client.py"
click node_auth_actions "https://github.com/sas5999/enterprise_api_framework-2/blob/main/actions/auth_actions.py"
click node_user_actions "https://github.com/sas5999/enterprise_api_framework-2/blob/main/actions/user_actions.py"
click node_conftest "https://github.com/sas5999/enterprise_api_framework-2/blob/main/conftest.py"
click node_smoke_tests "https://github.com/sas5999/enterprise_api_framework-2/blob/main/tests/smoke/test_smoke.py"
click node_auth_tests "https://github.com/sas5999/enterprise_api_framework-2/blob/main/tests/auth/test_auth.py"
click node_user_tests "https://github.com/sas5999/enterprise_api_framework-2/blob/main/tests/users/test_users.py"
click node_ci_workflow "https://github.com/sas5999/enterprise_api_framework-2/blob/main/.github/workflows/ci.yml"
click node_precommit "https://github.com/sas5999/enterprise_api_framework-2/blob/main/.pre-commit-config.yaml"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_config_settings,node_logger,node_helpers,node_user_schema,node_user_factory toneBlue
class node_endpoints,node_client toneAmber
class node_auth_actions,node_user_actions toneMint
class node_smoke_tests,node_auth_tests,node_user_tests toneRose
class node_conftest,node_ci_workflow,node_precommit toneIndigo
class node_external_api toneNeutral
```

## Components

### Foundation

Shared config, data, schemas, and utilities

- [Settings](https://github.com/sas5999/enterprise_api_framework-2/blob/main/config/settings.py): env config · Environment-driven runtime settings and thresholds · `config/settings.py`
- [Logger](https://github.com/sas5999/enterprise_api_framework-2/blob/main/utils/logger.py): logging · Cross-cutting request and test logging with redaction · `utils/logger.py`
- [Helpers](https://github.com/sas5999/enterprise_api_framework-2/blob/main/utils/helpers.py): assertion utils · Shared helper functions for retries, assertions, and instrumentation · `utils/helpers.py`
- [User Schema](https://github.com/sas5999/enterprise_api_framework-2/blob/main/schemas/user_schemas.py): contract · JSON schema contract for user API responses · `schemas/user_schemas.py`
- [User Factory](https://github.com/sas5999/enterprise_api_framework-2/blob/main/data/factories/user_factory.py): test data · Payload generation for positive and negative user cases · `data/factories/user_factory.py`

### API Layer

HTTP transport and endpoint definitions

- [Endpoints](https://github.com/sas5999/enterprise_api_framework-2/blob/main/api/endpoints.py): route map · Centralized endpoint path construction · `api/endpoints.py`
- [API Client](https://github.com/sas5999/enterprise_api_framework-2/blob/main/api/client.py): http transport · HTTP execution, response wrapping, retries, and metrics · `api/client.py`

### Action Layer

Resource-level business flows used by tests

- [Auth Actions](https://github.com/sas5999/enterprise_api_framework-2/blob/main/actions/auth_actions.py): resource flow · Authentication and registration operations · `actions/auth_actions.py`
- [User Actions](https://github.com/sas5999/enterprise_api_framework-2/blob/main/actions/user_actions.py): resource flow · User retrieval and CRUD-style business operations · `actions/user_actions.py`

### Test Layer

Pytest suites organized by concern

- [Smoke Suite](https://github.com/sas5999/enterprise_api_framework-2/blob/main/tests/smoke/test_smoke.py): pytest suite · Fast commit/PR gate tests · `tests/smoke/test_smoke.py`
- [Auth Suite](https://github.com/sas5999/enterprise_api_framework-2/blob/main/tests/auth/test_auth.py): pytest suite · Login and register coverage · `tests/auth/test_auth.py`
- [Users Suite](https://github.com/sas5999/enterprise_api_framework-2/blob/main/tests/users/test_users.py): pytest suite · User-focused API coverage · `tests/users/test_users.py`

### Orchestration

Pytest integration and CI workflow

- [Pytest Fixtures](https://github.com/sas5999/enterprise_api_framework-2/blob/main/conftest.py): pytest integration · Shared fixtures, session state, and reporting hooks · `conftest.py`
- [CI Workflow](https://github.com/sas5999/enterprise_api_framework-2/blob/main/.github/workflows/ci.yml): pipeline · Quality checks, smoke tests, full suite, and reporting · `.github/workflows/ci.yml`
- [Pre-commit](https://github.com/sas5999/enterprise_api_framework-2/blob/main/.pre-commit-config.yaml): local gate · Local hygiene checks before CI · `.pre-commit-config.yaml`

### Other components

- **External API**: target system · The third-party API under test, such as reqres.in

## Connections

- Smoke Suite → Auth Actions: calls · Smoke tests exercise business flows through actions
- Auth Suite → Auth Actions: calls · Auth tests invoke resource-level operations
- Users Suite → User Actions: calls · User tests invoke resource-level operations
- Auth Actions → API Client: uses · Action methods delegate transport to the API client
- User Actions → API Client: uses · Action methods delegate transport to the API client
- API Client → Endpoints: resolves · Client uses centralized endpoint paths
- API Client → External API: requests · HTTP calls exit the repo boundary to the target API
- Settings → API Client: configures · Settings provide base URL, timeouts, retries, and thresholds
- Settings → Auth Actions: configures · Actions can read environment-driven auth settings
- Settings → User Actions: configures · Actions can read environment-driven runtime settings
- Logger → API Client: observes · Client logs requests and responses with redaction
- Helpers → Auth Actions: supports · Shared helpers support assertions and retries
- Helpers → User Actions: supports · Shared helpers support assertions and retries
- User Schema → Users Suite: validates · Schema contracts are used to detect response drift
- User Factory → User Actions: feeds · Factory-generated payloads drive create and negative cases
- Pytest Fixtures → Smoke Suite: injects · Fixtures provide shared session state and reporting hooks
- Pytest Fixtures → Auth Suite: injects · Fixtures provide shared session state and reporting hooks
- Pytest Fixtures → Users Suite: injects · Fixtures provide shared session state and reporting hooks
- CI Workflow → Pre-commit: mirrors · CI complements local pre-commit hygiene
- CI Workflow → Smoke Suite: runs · Smoke tests run early in the pipeline
- CI Workflow → Auth Suite: runs · Full suite includes auth coverage
- CI Workflow → Users Suite: runs · Full suite includes user coverage
- CI Workflow → Pytest Fixtures: executes through · Pytest orchestration flows through shared fixtures
