# savianok/service-test- architecture

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

- Interactive diagram: https://gitdiagram.com/savianok/service-test-
- Repository: https://github.com/savianok/service-test-

## Overview

##### Project type and purpose
- This is an automated testing framework (“service-tests”) built in TypeScript with Mocha, designed to exercise RESTful services (contexts, languages, admin, webhook, etc.), validate database state via SQL, and produce reports (Allure).
- Key files/directories:
– api-methods/: axios wrappers for service endpoints
– sql/: DB connection & queries
– test/: Mocha specs
– test-data/: input fixtures
– helper/ & utils/: shared utilities (base64, object helpers, Allure steps)
– reporterConfig.json: test reporter settings
– CI/CD: Dockerfile, Jenkinsfile

##### Main components
a. Test Runner & Orchestration
– Mocha CLI (mocharc.js) driving tests in test/*.spec.ts
– Configuration from .env (via .env.example) and reporterConfig.json
b. API Client Layer
– api-methods/*.axios.ts (admin, basicAuth, contexts, languages, webhook)
c. Helper & Utility Modules
– helper/base64_encoded.ts, helper/object.ts
– utils/allureStep.ts for custom Allure reporting steps
d. Data Access Layer
– sql/contexts_db_connection.ts: DB connector
– sql/contexts-service.sql.ts: queries for validation
e. Test Data
– test-data/config-service.data.ts: fixtures used by tests
f. External Systems
– Target REST services: Contexts Service, Config Service, Authentication Service, Webhook endpoint
– Underlying database used by contexts service
g. Reporting & Artifacts
– Allure report generation via reporterConfig.json
h. CI/CD Pipeline
– Dockerfile: build container for tests
– Jenkinsfile: orchestrate build & test steps

##### Relationships and interactions
- Mocha Runner reads configuration → loads test suites → for each test:
→ uses api-methods to issue HTTP calls to external services
→ optionally runs SQL queries against the DB to assert state
→ logs steps to Allure via utils/allureStep
→ produces pass/fail results and writes reports
- CI/CD (Jenkins) → builds Docker image → injects .env vars → runs Mocha tests → archives Allure artifacts

##### Architectural patterns & design principles
- Layered Test Architecture: separation of concerns between test definitions, API clients, data helpers, and SQL.
- DRY utilities: helper and utils modules are shared across tests.
- Configuration as code: environment, reporter, and fixtures are externalized.
- Containerized CI pipeline: reproducible environment via Docker.

##### Detailed component breakdown (to include
– Mocha Runner (entry point, mocharc.js)
– API Methods: admin.axios.ts, contexts.axios.ts, languages.axios.ts, basicAuth.ts, webhook.ts
– Helpers: base64_encoded.ts, object.ts
– Utils: allureStep.ts
– SQL Layer: contexts_db_connection.ts + contexts-service.sql.ts
– Test Suites: contexts.spec.ts, languages.spec.ts
– Test Data: config-service.data.ts
– Configuration: .env (.env.example), reporterConfig.json, tsconfig.json
– Build/Deploy: Dockerfile, Jenkinsfile

## Diagram (Mermaid)

```mermaid
graph TD
    %% Test Framework Zone
    subgraph "Test Framework"
        MR["Mocha Runner"]:::code
        API["API Client Layer"]:::code
        HL["Helper Modules"]:::code
        UL["Utility Modules (Allure)"]:::code
        SQL["SQL Layer"]:::code
        TD["Test Data"]:::code
        TS["Test Suites"]:::code
        ENV["Environment Config (.env)"]:::code
        REP["Reporter Config"]:::code
        TSConf["TS Config"]:::code
    end

    %% External Services Zone
    subgraph "External Services"
        CSvc["Contexts Service"]:::external
        CFSvc["Config Service"]:::external
        Auth["Authentication Service"]:::external
        Webhook["Webhook Endpoint"]:::external
        DB["Database"]:::database
    end

    %% CI/CD Pipeline Zone
    subgraph "CI/CD Pipeline"
        JF["Jenkins"]:::ci
        DO["Docker"]:::ci
    end

    %% Artifact
    Allure["Allure Reports"]:::artifact

    %% Relationships
    ENV --> MR
    REP --> MR
    TSConf --> MR
    MR --> TS
    TS --> API
    TS --> HL
    TS --> UL
    TS --> SQL
    TS --> TD
    API --> CSvc
    API --> CFSvc
    API --> Auth
    API --> Webhook
    SQL --> DB
    TS --> Allure
    UL --> Allure
    JF --> DO
    DO --> MR
    MR --> Allure

    %% Click Events
    click MR "https://github.com/savianok/service-test-/blob/dev/.mocharc.js"
    click API "https://github.com/savianok/service-test-/tree/dev/api-methods/"
    click HL "https://github.com/savianok/service-test-/tree/dev/helper/"
    click UL "https://github.com/savianok/service-test-/blob/dev/utils/allureStep.ts"
    click SQL "https://github.com/savianok/service-test-/tree/dev/sql/"
    click TD "https://github.com/savianok/service-test-/blob/dev/test-data/config-service.data.ts"
    click TS "https://github.com/savianok/service-test-/tree/dev/test/"
    click REP "https://github.com/savianok/service-test-/blob/dev/reporterConfig.json"
    click ENV "https://github.com/savianok/service-test-/blob/dev/.env.example"
    click TSConf "https://github.com/savianok/service-test-/blob/dev/tsconfig.json"
    click DO "https://github.com/savianok/service-test-/tree/dev/Dockerfile"
    click JF "https://github.com/savianok/service-test-/tree/dev/Jenkinsfile"

    %% Styles
    classDef code fill:#AED6F1,stroke:#3498DB,color:#1B4F72
    classDef external fill:#ABEBC6,stroke:#27AE60,color:#145A32
    classDef database fill:#F9E79F,stroke:#D4AC0D,color:#7D6608
    classDef ci fill:#D2B4DE,stroke:#8E44AD,color:#4A235A
    classDef artifact fill:#F5CBA7,stroke:#D35400,color:#6E2C00
```
