# getstoix/template-dataflow-python architecture

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

- Interactive diagram: https://gitdiagram.com/getstoix/template-dataflow-python
- Repository: https://github.com/getstoix/template-dataflow-python

## Overview

##### Main Components

a) Input Sources:
- Cloud Storage (containing Shakespeare text files)
- Configuration Parameters (pipeline options)

b) Processing Components:
- Dataflow Flex Template Container
- Python Pipeline Components
- STOIX Dataflow Runner Container

c) Output Destinations:
- BigQuery (sharded tables)
- Temporary Storage (GCS)

##### Flow and Relationships

**[Input Layer] -> [Processing Layer] -> [Output Layer]**

Use these specific elements:

a) Input Layer:
- A configuration component showing pipeline parameters

b) Processing Layer:
- Inside the container, show:
- Dataflow Runner component
- Python Pipeline component with word counting logic
- STOIX orchestration layer above the container

c) Output Layer:
- BigQuery table with sharding indication
- Temporary GCS storage

##### Important Details to Highlight

- Blue: Google Cloud components (Storage, BigQuery)
- Green: Processing components (Dataflow)
- Orange: Configuration and parameters
- Gray: Container boundaries

- Clear labels for:
- Input file path (gs://dataflow-samples/shakespeare/...)
- Pipeline parameters (project, region, dataset, etc.)
- Output table naming pattern (including schedule date sharding)

##### Specific Architectural Elements

- Scheduling mechanism with STOIX
- Data transformation flow:
- Text input → Word counting → BigQuery output
- Temporary storage locations
- Service account authentication flow

##### Testing and Development Flow

A small separate section showing:
- Local development flow with Tox
- Testing pipeline with DirectRunner
- Production deployment with STOIX

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Styles and classes
    classDef gcp fill:#4285F4,stroke:#222,color:white
    classDef container fill:#D8E5F3,stroke:#222
    classDef process fill:#34A853,stroke:#222,color:white
    classDef config fill:#FBBC05,stroke:#222
    classDef testing fill:#EA4335,stroke:#222,color:white
    classDef docs fill:#gray,stroke:#222

    %% Input Layer
    subgraph Input
        GCS[("Cloud Storage\nInput Text")]:::gcp
        Config["Pipeline Parameters"]:::config
    end

    %% Processing Layer
    subgraph Processing
        subgraph Docker["Docker Container"]
            DF["Dataflow Runner"]:::process
            Pipeline["Python Pipeline\nWord Count Logic"]:::process
        end
        STOIX["STOIX Orchestration"]:::process
    end

    %% Output Layer
    subgraph Output
        BQ[("BigQuery\nSharded Tables")]:::gcp
        TempGCS[("Temporary\nStorage")]:::gcp
    end

    %% Testing and Development
    subgraph Development
        Tests["Pipeline Tests"]:::testing
        Tox["Tox Framework"]:::testing
        Local["Local Development"]:::testing
    end

    %% Documentation
    Docs["Documentation"]:::docs
    License["License"]:::docs

    %% Relationships
    GCS --> Docker
    Config --> Docker
    Docker --> BQ
    Docker --> TempGCS
    STOIX --> Docker
    Tests --> Pipeline
    Tox --> Tests
    Local --> Pipeline

    %% Click events
    click Docker "https://github.com/getstoix/template-dataflow-python/tree/main/Dockerfile"
    click Pipeline "https://github.com/getstoix/template-dataflow-python/blob/main/main.py"
    click Tests "https://github.com/getstoix/template-dataflow-python/blob/main/tests/test_pipeline.py"
    click Tox "https://github.com/getstoix/template-dataflow-python/blob/main/tox.ini"
    click License "https://github.com/getstoix/template-dataflow-python/tree/main/LICENSE"
    click Docs "https://github.com/getstoix/template-dataflow-python/blob/main/README.md"

    %% Legend
    subgraph Legend
        L1["GCP Services"]:::gcp
        L2["Processing"]:::process
        L3["Configuration"]:::config
        L4["Testing"]:::testing
        L5["Documentation"]:::docs
    end
```
