# redhatqe/tfacon architecture

> Architecture diagram of the GitHub repository redhatqe/tfacon, 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/redhatqe/tfacon
- Repository: https://github.com/redhatqe/tfacon

## Overview

##### Project type and purpose
- This is a command-line integration tool (tfacon) written in Go (with a Python pip package wrapper) whose job is to connect Test Management Platforms (currently Report Portal) to an AI/ML “Test Failure Analysis Classifier” (TFA) and an optional Recommendation Engine (RE).
- It is an open-source connector/CLI tool that fetches test items, invokes external ML services to predict defect types, and updates the test platform.

##### File structure
- Top-level directories:
- cmd/       → CLI commands (root, list, run, validate, init, revert)
- core/      → Orchestration of core logic (fetch data, drive predictions, assemble results)
- connectors/→ Abstraction and implementation of connectors (Report Portal “RPCon”, placeholders for Polarion, Jira)
- common/    → Shared types, helpers, config parsing and validation
- pip_package/ → Python packaging for pip install
- Configuration files:
- tfacon.yml (user parameters for launches, tokens, URLs)
- tfacon.cfg (advanced tool behavior: concurrency, retry, attributes)
- Build & CI: Makefile, Go modules, GitHub Workflows, linting, publishing to PyPI.
- Tests and examples live under `test_data`, `examples`, and `*_test.go` files.

##### README for additional insights
- Describes CLI commands and flags, sample outputs, and a UML graph of the internal package/module dependency.
- External systems: Report Portal API, TFA classifier API endpoint, optional Recommendation Engine endpoint.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% CLI Frontend Layer
    subgraph "CLI Frontend" 
        direction TB
        Root["root.go"]:::internal
        Run["run.go"]:::internal
        Init["init.go"]:::internal
        List["list.go"]:::internal
        Validate["validate.go"]:::internal
        Revert["revert.go"]:::internal
        CmdUtils["cmd_utils.go"]:::internal
    end

    %% Configuration Loader Layer
    subgraph "Configuration Loader" 
        direction TB
        CommonGo["common.go"]:::config
        Helpers["helpers.go"]:::config
    end

    %% Core Orchestrator Layer
    subgraph "Core Orchestrator"
        direction TB
        Orchestrator["tfacon.go"]:::internal
    end

    %% Connector Layer
    subgraph "Connectors"
        direction TB
        ConnectorIface["Connector Interface"]:::internal
        RPConnector["rp_connector.go"]:::internal
    end

    %% Python Pip Package Wrapper
    subgraph "Pip Package Wrapper"
        direction TB
        SetupPy["setup.py"]:::internal
        SetupCfg["setup.cfg"]:::internal
        Manifest["MANIFEST.in"]:::internal
        InstallScript["install_tfacon.sh"]:::internal
        PipInit["__init__.py"]:::internal
    end

    %% Local Workspace & Examples
    subgraph "Local Workspace & Examples"
        direction TB
        ExampleYML["examples/tfacon.yml"]:::config
        ExampleCFG["examples/tfacon.cfg"]:::config
        TestDataYML["test_data/workspace_data"]:::config
    end

    %% External Services
    subgraph "External Services"
        direction TB
        ReportPortal["Report Portal API"]:::external
        TFAService["TFA Classifier Service"]:::external
        REngine["Recommendation Engine"]:::external
    end

    %% Relationships
    User["User"]:::external -->|"tfacon <command>"| Root
    Root -->|invokes| CommonGo
    Root -->|invokes| Helpers
    Root -->|calls| Orchestrator

    Orchestrator -->|uses| ConnectorIface
    ConnectorIface -->|implemented by| RPConnector
    Orchestrator -->|GET /items| ReportPortal
    Orchestrator -->|POST /predict| TFAService
    Orchestrator -.->|optional POST /recommend| REngine
    Orchestrator -->|POST /update| ReportPortal
    Orchestrator -->|returns summary| Root
    Root -->|"prints summary"| User

    %% Click Events
    click Root "https://github.com/redhatqe/tfacon/blob/develop/cmd/root.go"
    click Run "https://github.com/redhatqe/tfacon/blob/develop/cmd/run.go"
    click Init "https://github.com/redhatqe/tfacon/blob/develop/cmd/init.go"
    click List "https://github.com/redhatqe/tfacon/blob/develop/cmd/list.go"
    click Validate "https://github.com/redhatqe/tfacon/blob/develop/cmd/validate.go"
    click Revert "https://github.com/redhatqe/tfacon/blob/develop/cmd/revert.go"
    click CmdUtils "https://github.com/redhatqe/tfacon/blob/develop/cmd/cmd_utils.go"
    click CommonGo "https://github.com/redhatqe/tfacon/blob/develop/common/common.go"
    click Helpers "https://github.com/redhatqe/tfacon/blob/develop/common/helpers.go"
    click Orchestrator "https://github.com/redhatqe/tfacon/blob/develop/core/tfacon.go"
    click RPConnector "https://github.com/redhatqe/tfacon/blob/develop/connectors/rp_connector.go"
    click SetupPy "https://github.com/redhatqe/tfacon/blob/develop/pip_package/setup.py"
    click SetupCfg "https://github.com/redhatqe/tfacon/blob/develop/pip_package/setup.cfg"
    click Manifest "https://github.com/redhatqe/tfacon/blob/develop/pip_package/MANIFEST.in"
    click InstallScript "https://github.com/redhatqe/tfacon/blob/develop/pip_package/scripts/install_tfacon.sh"
    click PipInit "https://github.com/redhatqe/tfacon/blob/develop/pip_package/tfacon_pip/__init__.py"
    click ExampleYML "https://github.com/redhatqe/tfacon/blob/develop/examples/tfacon.yml"
    click ExampleCFG "https://github.com/redhatqe/tfacon/blob/develop/examples/tfacon.cfg"
    click TestDataYML "https://github.com/redhatqe/tfacon/tree/develop/test_data/workspace_data"

    %% Styles
    classDef internal fill:#AED6F1,stroke:#1B4F72,color:#000;
    classDef external fill:#ABEBC6,stroke:#145A32,color:#000;
    classDef config fill:#F9E79F,stroke:#B9770E,color:#000;
    class RPConnector,ConnectorIface internal;
    class ReportPortal,TFAService,REngine external;
```
