# manudelaguila/tealiumapi architecture

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

## Overview

##### Main Components
- Environment & Dependency Management: There is a requirements.txt along with instructions to create and use a Python virtual environment.
- Version-Specific Modules: Two distinct directories (v2 and v3) for handling the respective versions of the Tealium API.
- Configuration Files: Each version directory contains an example token file (tealiumTokenV2_example.json and tealiumTokenV3_example.json) that should be copied and renamed as tealiumTokenV2.json or tealiumTokenV3.json. These files provide the necessary API configuration details (API key, email, account, etc.).
- API Client Modules: The Python scripts (tealium_api_v2.py and tealium_api_v3.py) encapsulate the logic to interact with the Tealium API.

##### Relationships and Interactions
- The User sets up the environment, installs dependencies from requirements.txt, and edits the configuration files to include valid credentials.
- The API client modules (one for V2 and one for V3) read the corresponding configuration (token) files.
- These modules then establish communication with the external Tealium API endpoints, performing actions as specified (e.g., retrieving version details, updating load rules).
- There is a clear separation between the two API versions, which allows for isolated error tracking (as noted in the README) and potentially parallel development or testing.

##### Architectural Patterns and Technologies
- Modularity: Different API versions are handled in separate directories, promoting separation of concerns.
- Configuration Over Convention: The use of JSON token files to configure the API interactions, permitting flexibility.
- External Integration: The system solely acts as an intermediary for API calls to Tealium, which means that its primary responsibility is to correctly format requests and handle API responses.
- Python Virtual Environment & Dependency Management: Standard best practices for managing dependencies in Python are highlighted.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Environment Setup
    subgraph "Environment Setup"
        ENV["Virtual Environment & Dependencies"]:::internal
    end

    %% Tealium V2 Module
    subgraph "Tealium V2 Module"
        V2_CONFIG["Tealium V2 Config"]:::internal
        V2_CLIENT["Tealium V2 API Client"]:::internal
        V2_CONFIG -->|"reads_config"| V2_CLIENT
    end

    %% Tealium V3 Module
    subgraph "Tealium V3 Module"
        V3_CONFIG["Tealium V3 Config"]:::internal
        V3_CLIENT["Tealium V3 API Client"]:::internal
        V3_CONFIG -->|"reads_config"| V3_CLIENT
    end

    %% External Tealium API
    EXT_API["External Tealium API"]:::external

    %% Relationships from Environment to Modules
    ENV -->|"setup"| V2_CONFIG
    ENV -->|"setup"| V3_CONFIG

    %% API Clients calling External API
    V2_CLIENT -->|"API_calls"| EXT_API
    V3_CLIENT -->|"API_calls"| EXT_API

    %% Click Events
    click ENV "https://github.com/manudelaguila/tealiumapi/blob/main/requirements.txt"
    click V2_CONFIG "https://github.com/manudelaguila/tealiumapi/blob/main/v2/tealiumTokenV2_example.json"
    click V2_CLIENT "https://github.com/manudelaguila/tealiumapi/blob/main/v2/tealium_api_v2.py"
    click V3_CONFIG "https://github.com/manudelaguila/tealiumapi/blob/main/v3/tealiumTokenV3_example.json"
    click V3_CLIENT "https://github.com/manudelaguila/tealiumapi/blob/main/v3/tealium_api_v3.py"

    %% Styles
    classDef internal fill:#AED6F1,stroke:#1B4F72,stroke-width:2px;
    classDef external fill:#F1948A,stroke:#922B21,stroke-width:2px;
```
