# trusted-ai/adversarial-robustness-toolbox architecture

> Architecture diagram of the GitHub repository trusted-ai/adversarial-robustness-toolbox, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-03-29). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/trusted-ai/adversarial-robustness-toolbox
- Repository: https://github.com/trusted-ai/adversarial-robustness-toolbox

## Overview

##### Main Components
- Core Modules:
- Attacks: This module includes various adversarial approaches (evasion, poisoning, extraction, inference) with subdirectories such as art/attacks and further nested submodules (e.g., adversarial_patch, carlini, auto_attack).
- Defences: This part of the library provides mechanisms to detect and mitigate adversarial behavior. It is structured into categories like detector, preprocessor, postprocessor, trainer, and transformers.
- Estimators: These components wrap models and provide interfaces for classification, object detection, speech recognition, regression, and certification. Multiple subdirectories distinguish between framework-specific implementations (e.g., art/estimators/classification, art/estimators/object_detection, art/estimators/speech_recognition).
- Metrics & Evaluations: For assessing model performance and adversarial robustness (found in art/metrics and art/evaluations).
- Preprocessing & Utilities: Covering data generators, preprocessing steps for images, audio, etc., alongside general utilities (art/preprocessing, art/utils).
- Supporting Components:
- Examples and Notebooks: They illustrate how ART can be used, demonstrating typical workflows and integration in user projects (examples/, notebooks/).
- Tests: A comprehensive suite ensuring the reliability of each module (tests/ directories mirror the structure of the main components).
- Documentation and Configurations: Contains technical docs (docs/), continuous integration workflows (.github/), and Dockerfiles for reproducible environments.
- Deployment and ML Ops Utilities: Under the “utils/mlops” folder and Kubeflow integration files, which reveal how the toolbox is used in deployment pipelines.

##### Relationships and Interactions
- Interactions among modules – for example:
- The Estimators interact with both Defences (e.g., defensive distillation, adversarial training using trainers) and Attacks (to generate adversarial examples).
- Preprocessing components feed data into model pipelines.
- Metrics and Evaluation modules capture performance and robustness outputs from various attacks and defences.

##### Architectural Patterns
- Modular and Layered Architecture: Each major function (attack, defence, estimation, preprocessing) is encapsulated in its own module with well-defined responsibilities.
- Plugin-Like Extensibility: New attacks, defences, or novel estimators can be added as separate submodules due to the well-structured package design.
- Abstraction over multiple ML Frameworks: The system uses a consistent interface for different underlying frameworks (TensorFlow, PyTorch, scikit-learn, etc.), which should be emphasized by grouping framework-specific implementations under each core module.
- Testing and CI/CD Integration: The presence of thorough tests and GitHub Actions workflows indicates that the design supports continuous integration and extensive validation of each component.

##### Technologies and Frameworks
- Wide array of supported frameworks (TensorFlow, PyTorch, Keras, etc.) should be highlighted.
- Docker and CI/CD automation (with workflows and Dockerfiles in .github/) ensure a reproducible environment.
- ML Ops integration via Kubeflow in the “utils/mlops” directory demonstrates the toolbox’s readiness for deployment in production pipelines.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Client Interface Layer
    subgraph "Client Interface"
        Client["Client/External API"]:::client
        Ex["Examples"]:::support
        Note["Notebooks"]:::support
    end

    %% Core Modules Layer
    subgraph "Core Modules"
        A["Attacks"]:::core
        D["Defences"]:::core
        PP["Preprocessing"]:::core
        UU["Utilities"]:::core
        E["Estimators"]:::core
        M["Metrics & Evaluations"]:::core
    end

    %% Supporting Infrastructure Layer
    subgraph "Supporting Infrastructure"
        T["Tests"]:::support
        Docs["Documentation & CI Config"]:::support
        Dep["Deployment & ML Ops Utilities"]:::support
    end

    %% Connections from Client Interface to Core Modules
    Client --> Ex
    Client --> Note
    Ex --> A
    Ex --> D
    Ex --> E
    Note --> A
    Note --> D
    Note --> E

    %% Interactions within Core Modules
    A -->|"Generates_adversarial_examples"| E
    D -->|"Mitigates_attacks"| E
    PP -->|"Feeds_data"| E
    UU -->|"Provides_helpers"| E
    E -->|"Delivers_results"| M
    A -->|"Supplies_attack_data"| M
    D -->|"Supplies_defence_data"| M

    %% Connections from Core Modules to Supporting Infrastructure
    A --> T
    D --> T
    PP --> T
    UU --> T
    E --> T
    M --> T

    T --> Docs
    Docs --> Dep
    E --> Dep

    %% Styling for nodes
    classDef core fill:#ADD8E6,stroke:#0000FF,stroke-width:2px;
    classDef support fill:#90EE90,stroke:#008000,stroke-width:2px;
    classDef client fill:#FFD700,stroke:#DAA520,stroke-width:2px;

    %% Click Events for Component Mappings
    click A "https://github.com/trusted-ai/adversarial-robustness-toolbox/tree/main/art/attacks"
    click D "https://github.com/trusted-ai/adversarial-robustness-toolbox/tree/main/art/defences"
    click E "https://github.com/trusted-ai/adversarial-robustness-toolbox/tree/main/art/estimators"
    click M "https://github.com/trusted-ai/adversarial-robustness-toolbox/tree/main/art/metrics"
    click PP "https://github.com/trusted-ai/adversarial-robustness-toolbox/tree/main/art/preprocessing"
    click UU "https://github.com/trusted-ai/adversarial-robustness-toolbox/tree/main/art/utils"
    click Ex "https://github.com/trusted-ai/adversarial-robustness-toolbox/tree/main/examples/"
    click Note "https://github.com/trusted-ai/adversarial-robustness-toolbox/tree/main/notebooks/"
    click T "https://github.com/trusted-ai/adversarial-robustness-toolbox/tree/main/tests/"
    click Docs "https://github.com/trusted-ai/adversarial-robustness-toolbox/tree/main/.github/"
    click Dep "https://github.com/trusted-ai/adversarial-robustness-toolbox/tree/main/utils/mlops"
```
