# tableau/tabcmd architecture

> Architecture diagram of the GitHub repository tableau/tabcmd, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2024-12-28). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/tableau/tabcmd
- Repository: https://github.com/tableau/tabcmd

## Overview

##### Main Components

a. Command Layer:
- Commands by functionality domains (auth, datasources_and_workbooks, extracts, group, project, site, user)
- Command controller (tabcmd_controller.py) as the central orchestrator

b. Execution Layer:
- Global options handling
- Localization system
- Logging system
- Version management

c. External Integration:
- Tableau Server/Cloud API interaction
- Authentication/Session management
- File system interactions for import/export

##### Architecture Pattern
The project follows a Command Pattern architecture with these key elements:

- Command Parser/Router
- Command Executors
- Global State Management
- Internationalization (i18n) Support

**[User CLI Input] → [Parent Parser] → [Command Router]**
- ↓
**[Global Options] → [TabCmd Controller] ← [Command Executors]**
- ↓                                     ↓
**[Session Management] → [Tableau Server/Cloud API]**

##### Key Relationships

a. Command Flow:
**CLI Input → Parser → Command Mapping → Command Execution → API Calls**

b. Support Systems Integration:
**Localization System ←→ Command Execution**
**Logging System ←→ All Components**
**Global Options ←→ Command Execution**

##### Important Implementation Details

- Command categories as separate modules:
- Authentication Commands
- Datasource/Workbook Management
- Extract Management
- User Management
- Site Management
- Project Management

- Cross-cutting concerns:
- Session Management
- Logging
- Internationalization
- Configuration

**→ : Data/Control Flow**
**↔ : Bidirectional Communication**
**⟲ : Recurring Process**
**□ : Core Component**
**◇ : Decision Point**
**○ : Support System**

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph CLI["Command Line Interface"]
        Input[User Input]
    end

    subgraph Parser["Parser Layer"]
        PP["Parent Parser"]:::parser
        GlobOpt["Global Options Handler"]:::options
        CmdMap["Command Mapping"]:::mapper
    end

    subgraph Controller["Control Layer"]
        TabCmd["TabCmd Controller"]:::controller
    end

    subgraph Commands["Command Modules"]
        direction TB
        Auth["Authentication Commands"]:::command
        DSWork["Datasources & Workbooks"]:::command
        Extract["Extracts Commands"]:::command
        Group["Group Commands"]:::command
        Project["Project Commands"]:::command
        Site["Site Commands"]:::command
        User["User Commands"]:::command
    end

    subgraph Support["Support Systems"]
        direction TB
        Local["Localization System"]:::support
        Log["Logging System"]:::support
        Version["Version Management"]:::support
    end

    subgraph Integration["External Integration"]
        Session["Session Management"]:::integration
        ServerAPI["Server API Interface"]:::integration
    end

    subgraph External["External Systems"]
        TableauServer["Tableau Server/Cloud"]:::external
    end

    Input --> PP
    PP --> GlobOpt
    PP --> CmdMap
    GlobOpt --> TabCmd
    CmdMap --> TabCmd

    TabCmd --> Auth
    TabCmd --> DSWork
    TabCmd --> Extract
    TabCmd --> Group
    TabCmd --> Project
    TabCmd --> Site
    TabCmd --> User

    Auth --> Session
    Session --> ServerAPI
    DSWork --> ServerAPI
    Extract --> ServerAPI
    Group --> ServerAPI
    Project --> ServerAPI
    Site --> ServerAPI
    User --> ServerAPI

    ServerAPI --> TableauServer

    Local -.-> TabCmd
    Log -.-> TabCmd
    Version -.-> TabCmd

    %% Click events for component mapping
    click TabCmd "https://github.com/tableau/tabcmd/blob/main/tabcmd/execution/tabcmd_controller.py"
    click Auth "https://github.com/tableau/tabcmd/tree/main/tabcmd/commands/auth/"
    click DSWork "https://github.com/tableau/tabcmd/tree/main/tabcmd/commands/datasources_and_workbooks/"
    click Extract "https://github.com/tableau/tabcmd/tree/main/tabcmd/commands/extracts/"
    click Group "https://github.com/tableau/tabcmd/tree/main/tabcmd/commands/group/"
    click Project "https://github.com/tableau/tabcmd/tree/main/tabcmd/commands/project/"
    click Site "https://github.com/tableau/tabcmd/tree/main/tabcmd/commands/site/"
    click User "https://github.com/tableau/tabcmd/tree/main/tabcmd/commands/user/"
    click GlobOpt "https://github.com/tableau/tabcmd/blob/main/tabcmd/execution/global_options.py"
    click Local "https://github.com/tableau/tabcmd/blob/main/tabcmd/execution/localize.py"
    click Log "https://github.com/tableau/tabcmd/blob/main/tabcmd/execution/logger_config.py"
    click Version "https://github.com/tableau/tabcmd/blob/main/tabcmd/execution/_version.py"
    click PP "https://github.com/tableau/tabcmd/blob/main/tabcmd/execution/parent_parser.py"
    click ServerAPI "https://github.com/tableau/tabcmd/blob/main/tabcmd/commands/server.py"
    click Session "https://github.com/tableau/tabcmd/blob/main/tabcmd/commands/auth/session.py"
    click CmdMap "https://github.com/tableau/tabcmd/blob/main/tabcmd/execution/map_of_commands.py"

    %% Styling
    classDef parser fill:#9cf
    classDef options fill:#fcf
    classDef mapper fill:#cfc
    classDef controller fill:#f9c
    classDef command fill:#ccf
    classDef support fill:#ffc
    classDef integration fill:#cff
    classDef external fill:#ddd

    %% Legend
    subgraph Legend
        direction TB
        L1["Parser Component"]:::parser
        L2["Options Component"]:::options
        L3["Mapper Component"]:::mapper
        L4["Controller Component"]:::controller
        L5["Command Module"]:::command
        L6["Support System"]:::support
        L7["Integration Layer"]:::integration
        L8["External System"]:::external
    end
```
