# keboola/python-component architecture

> Architecture diagram of the GitHub repository keboola/python-component, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-01-22). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/keboola/python-component
- Repository: https://github.com/keboola/python-component

## Overview

##### Main Components and Layers

a) Core Library Layer (Center):
- Interface Module (Blue)
- DAO Module (Green)
- Base Module (Orange)

b) Infrastructure Layer (Bottom):
- Keboola Common Interface
- Docker Environment
- File System (Data Directory)

c) Integration Layer (Top):
- Component Implementation
- Python Transformations
- Keboola Connection

##### Component Relationships

a) Core Components:
**CommonInterface**
- Configuration Management
- Environment Variables
- Data Folder Management
- Manifest Processing
- Logging System

b) Data Access Objects:
**DAO**
- TableDefinition
- FileDefinition
- TableMetadata
- ColumnDefinition

c) Base Components:
**ComponentBase**
- Sync Actions
- Configuration Validation
- Execution Flow

##### Specific Elements

a) Input/Output Processing:
- Input Tables/Files Processing
- Output Tables/Files Generation
- Manifest File Handling
- State File Management

b) Configuration Flow:
- Environment Variables
- Config.json Processing
- Parameter Validation

c) Execution Flow:
- Sync Actions Processing
- Error Handling
- Logging System

##### Additional Details

- Component types
- Special symbols

Annotations for:
- Required environment variables
- Critical file paths
- Important configuration parameters

##### Implementation Notes

- The library's role as a wrapper/abstraction layer
- The separation of concerns between interface, data objects, and base components
- The automated handling of common tasks (logging, configuration, validation)
- The extensibility points for custom components

##### Key Interactions to Highlight

- Component initialization flow
- Configuration validation process
- Table/File manifest processing
- Sync action execution flow
- Error handling and logging paths

Remember to include version information and any critical dependencies, as this will help developers understand the complete ecosystem of the component library.

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph Core_Library
        Interface["Interface Module"]
        DAO["DAO Module"]
        Base["Base Module"]
    end

    subgraph Common_Interface
        CI["CommonInterface"]
        ConfigMgr["Configuration Management"]
        EnvVars["Environment Variables"]
        DataHandler["Data Folder Handler"]
        Logger["Logging System"]
        StateMgr["State File Manager"]
    end

    subgraph Data_Objects
        TD["TableDefinition"]
        FD["FileDefinition"]
        CD["ColumnDefinition"]
        TM["TableMetadata"]
    end

    subgraph Component_Base
        CB["ComponentBase Class"]
        SA["Sync Actions Handler"]
        CV["Configuration Validator"]
    end

    subgraph Infrastructure
        KBC["Keboola Connection Platform"]
        Docker["Docker Container Runtime"]
        FS["File System Interface"]
    end

    subgraph Storage
        IT["Input Tables/Files"]
        OT["Output Tables/Files"]
        SS["State Storage"]
        CS["Configuration Storage"]
    end

    %% Core relationships
    Interface --> CI
    DAO --> TD
    DAO --> FD
    DAO --> CD
    DAO --> TM
    Base --> CB

    %% Common Interface relationships
    CI --> ConfigMgr
    CI --> EnvVars
    CI --> DataHandler
    CI --> Logger
    CI --> StateMgr

    %% Component Base relationships
    CB --> SA
    CB --> CV
    CB --> CI

    %% Infrastructure connections
    CI --> KBC
    KBC --> Docker
    Docker --> FS

    %% Storage relationships
    DataHandler --> IT
    DataHandler --> OT
    StateMgr --> SS
    ConfigMgr --> CS

    %% Styling
    classDef core fill:#2374ab
    classDef data fill:#57a773
    classDef config fill:#ffc857
    classDef infra fill:#808080
    classDef error fill:#ed474a

    class Interface,DAO,Base core
    class TD,FD,CD,TM data
    class ConfigMgr,StateMgr,CS,SS config
    class KBC,Docker,FS infra

    %% Click events
    click Interface "https://github.com/keboola/python-component/blob/main/src/keboola/component/interface.py"
    click DAO "https://github.com/keboola/python-component/blob/main/src/keboola/component/dao.py"
    click Base "https://github.com/keboola/python-component/blob/main/src/keboola/component/base.py"
    click SA "https://github.com/keboola/python-component/blob/main/src/keboola/component/sync_actions.py"
    click TD "https://github.com/keboola/python-component/blob/main/src/keboola/component/table_schema.py"
    click ConfigMgr "https://github.com/keboola/python-component/blob/main/tests/data_examples/data1/config.json"
    click StateMgr "https://github.com/keboola/python-component/blob/main/tests/data_examples/data1/in/state.json"
    click IT "https://github.com/keboola/python-component/blob/main/tests/data_examples/data1/in/tables/sample.csv.manifest"
    click CV "https://github.com/keboola/python-component/tree/main/tests/schema_examples/schemas/"
```
