# markphamm/jaffle-stripe-transformation-pipeline architecture

> Architecture diagram of the GitHub repository markphamm/jaffle-stripe-transformation-pipeline, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-04-06). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/markphamm/jaffle-stripe-transformation-pipeline
- Repository: https://github.com/markphamm/jaffle-stripe-transformation-pipeline

## Overview

##### Main Components
- Data Sources:
- Jaffle Shop – represented by seed CSV files and raw input data.
- Stripe – represented through API credentials/setup and configuration (e.g., stripe.yml).
- Transformation Engine (dbt Pipeline):
- Staging Layer – “models/staging” contains raw-cleaning scripts for jaffle_shop and stripe data.
- Intermediate Models – combining or transforming data across sources.
- Mart Layer – “models/marts” that produce final business datasets (e.g., finance, customers, marketing).
- Data Quality & Testing:
- dbt tests, located in the “tests” directories, to ensure data quality.
- Documentation & Macros:
- Auto-generated documentation components and reusable SQL logic (macros).
- Orchestration / DAG Runner:
- The DAG files (in dbt-dags/dags) and transformation_dag.py indicate an external orchestration layer (possibly using Airflow or Astro) to schedule and coordinate pipeline runs.
- Environment & Deployment:
- Data Warehouse:
- Though not part of the repo, include an external component representing the target data warehouse (e.g., BigQuery, Snowflake).

##### Relationships and Data Flow
- The orchestration component (DAG Runner) should be connected to trigger the dbt processes.
- Finally, the output data (analytics-ready mart tables) flows into the external Data Warehouse.

##### Architectural Patterns and Design Principles
- Separation of concerns: clear segmentation between raw ingestion (staging), transformation (intermediate), and final presentation layers (marts).
- Modularity: making use of reusable SQL macros and tests.
- Idempotency and data quality: indicating built-in tests and auto-generated docs to facilitate data lineage.
- Containerized orchestration and deployment: showing Docker integration and scheduled execution via DAGs.

##### Technologies and Frameworks
- dbt (data build tool) for transformations.
- Python (for orchestration, as seen in the DAG files and transformation_dag.py).
- Docker for deployment.
- Airflow or Astro as potential orchestration engines (hinted by the dbt-dags/.astro directory).
- Data warehouse (like BigQuery/Snowflake) as the final target, though externally configured.

## Diagram (Mermaid)

```mermaid
graph TD
    %% Data Sources
    DS1["Jaffle Shop Data"]:::source
    DS2["Stripe Data"]:::source

    %% Data Ingestion - Jaffle Shop
    JS_Seeds["Seed Data (Jaffle Shop)"]:::dbt
    JS_Staging["Staging: Jaffle Shop"]:::dbt

    %% Data Ingestion - Stripe
    ST_Staging["Staging: Stripe"]:::dbt

    %% Intermediate Transformation
    Intermediate["Intermediate Models"]:::intermediate

    %% Mart Layer
    MartModels["Mart Models"]:::mart
    Finance["Finance Mart"]:::mart
    Marketing["Marketing Mart"]:::mart

    %% Data Quality & Testing
    DbtTests["DBT Tests"]:::testing
    DagTests["DAG Tests"]:::testing
    Quality["Data Quality & Testing"]:::testing

    %% Documentation & Macros
    Docs["Documentation & Macros"]:::documentation

    %% Orchestration / DAG Runner Subgraph
    subgraph "Orchestration / DAG Runner"
        DAGConfig["DAG Config"]:::orchestration
        TransDAG["Transformation DAG"]:::orchestration
        OrchestrationConfig["Orchestration Config"]:::orchestration
    end

    %% Deployment & Environment Subgraph
    subgraph "Deployment & Environment"
        Docker["Dockerfile"]:::deployment
        EnvConfig["Env Config"]:::deployment
    end

    %% Final Target
    Warehouse["Data Warehouse"]:::external

    %% Main Data Flow
    DS1 -->|"provides raw & seed"| JS_Seeds
    DS1 -->|"provides raw data"| JS_Staging
    DS2 -->|"provides configuration & raw data"| ST_Staging

    %% Orchestration triggers ingestion
    DAGConfig --- JS_Staging
    DAGConfig --- ST_Staging
    TransDAG --- JS_Seeds

    %% Merge staging into intermediate transformation
    JS_Seeds --> Intermediate
    JS_Staging --> Intermediate
    ST_Staging --> Intermediate

    %% Documentation support branch (dotted connection)
    Intermediate -.-> Docs

    %% Transformation flow to Mart Layer
    Intermediate --> MartModels
    MartModels --> Finance
    MartModels --> Marketing

    %% Data Quality & Testing after mart models
    Finance --> Quality
    Marketing --> Quality
    Quality --> DbtTests
    Quality --> DagTests

    %% Final load to Data Warehouse
    Quality --> Warehouse

    %% Deployment influences orchestration (dashed arrow)
    EnvConfig -.-> DAGConfig

    %% Click Events
    click JS_Seeds "https://github.com/markphamm/jaffle-stripe-transformation-pipeline/tree/main/dbt-dags/dags/dbt/jaffle_stripe/seeds"
    click JS_Staging "https://github.com/markphamm/jaffle-stripe-transformation-pipeline/tree/main/dbt-dags/dags/dbt/jaffle_stripe/models/staging/jaffle_shop"
    click ST_Staging "https://github.com/markphamm/jaffle-stripe-transformation-pipeline/tree/main/dbt-dags/dags/dbt/jaffle_stripe/models/staging/stripe"
    click MartModels "https://github.com/markphamm/jaffle-stripe-transformation-pipeline/tree/main/dbt-dags/dags/dbt/jaffle_stripe/models/marts"
    click Finance "https://github.com/markphamm/jaffle-stripe-transformation-pipeline/tree/main/dbt-dags/dags/dbt/jaffle_stripe/models/marts/finance"
    click Marketing "https://github.com/markphamm/jaffle-stripe-transformation-pipeline/tree/main/dbt-dags/dags/dbt/jaffle_stripe/models/marts/marketing"
    click DbtTests "https://github.com/markphamm/jaffle-stripe-transformation-pipeline/tree/main/dbt-dags/dags/dbt/jaffle_stripe/tests"
    click DagTests "https://github.com/markphamm/jaffle-stripe-transformation-pipeline/tree/main/dbt-dags/tests/dags"
    click Docs "https://github.com/markphamm/jaffle-stripe-transformation-pipeline/tree/main/dbt-dags/dags/dbt/jaffle_stripe/macros"
    click TransDAG "https://github.com/markphamm/jaffle-stripe-transformation-pipeline/blob/main/dbt-dags/dags/transformation_dag.py"
    click DAGConfig "https://github.com/markphamm/jaffle-stripe-transformation-pipeline/tree/main/dbt-dags/dags"
    click OrchestrationConfig "https://github.com/markphamm/jaffle-stripe-transformation-pipeline/blob/main/dbt-dags/.astro/config.yaml"
    click Docker "https://github.com/markphamm/jaffle-stripe-transformation-pipeline/tree/main/dbt-dags/Dockerfile"
    click EnvConfig "https://github.com/markphamm/jaffle-stripe-transformation-pipeline/blob/main/dbt-dags/.astro/config.yaml"

    %% Styles
    classDef source fill:#f9e79f,stroke:#b9770e,stroke-width:2px;
    classDef dbt fill:#d5f5e3,stroke:#27ae60,stroke-width:2px;
    classDef intermediate fill:#fadbd8,stroke:#c0392b,stroke-width:2px;
    classDef mart fill:#d6eaf8,stroke:#2980b9,stroke-width:2px;
    classDef testing fill:#fcf3cf,stroke:#f1c40f,stroke-width:2px;
    classDef orchestration fill:#e8daef,stroke:#8e44ad,stroke-width:2px;
    classDef deployment fill:#f5b7b1,stroke:#c0392b,stroke-width:2px;
    classDef documentation fill:#d2b4de,stroke:#6c3483,stroke-width:2px;
    classDef external fill:#e8f8f5,stroke:#1abc9c,stroke-width:2px;
```
