# snowplow/dbt-snowplow-attribution architecture

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

- Interactive diagram: https://gitdiagram.com/snowplow/dbt-snowplow-attribution
- Repository: https://github.com/snowplow/dbt-snowplow-attribution

## Overview

##### Main Components

a) Data Sources Layer:
- Snowplow Unified Views (touch points source)
- Snowplow Unified Conversions (conversion data)
- Marketing Spend Data (optional source)

b) Processing Layer:
- Path Transformation Components
- Attribution Models
- Incremental Processing Logic

c) Output Models Layer:
- Core Attribution Models
- Optional Reporting Models
- Manifest Management

**┌─────────────────┐    ┌──────────────────┐    ┌─────────────┐**
- Unified Views  │    │    Conversions   │    │Marketing Spend│
- ┬────────┘    └────────┬─────────┘    └──────┬──────┘

**┌─────────────────────────────────────────────────────────┐**
- Path Transformation Logic                 │
- ┌─────────────┐    ┌─────────────┐    ┌────────────┐  │
- Create UDFs   │─-->│Transform    │─-->│Trim Paths  │  │
- ┘    │Paths        │    └────────────┘  │
- ┘

**┌─────────────────┐    ┌─────────────────┐    ┌────────────┐**
- Paths to         │    │Campaign/Channel  │    │Attribution │
- Conversion       │    │Attribution       │    │Overview    │
- ┘    └─────────────────┘    └────────────┘

##### Key Relationships to Highlight

- How the unified views feed into the path transformation logic
- Connection between conversions data and attribution models
- Demonstrate how the manifest table manages incremental processing
- Relationship between channel/campaign attributions and the overview

##### Important Technical Details

- Supported platforms (Snowflake, BigQuery, Databricks & Redshift)
- Incremental processing flow
- Different attribution algorithms available
- Version requirements (dbt-core 1.6.0+)

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph "Data Sources"
        UV["Snowplow Unified Views"]:::source
        CD["Snowplow Unified Conversions"]:::source
        MS["Marketing Spend Data"]:::source_optional
    end

    subgraph "Path Processing"
        PT["Path Transformation Logic"]:::processing
        UDF["Create UDFs"]:::processing
        TF["Transform Paths"]:::processing
        TP["Trim Paths"]:::processing
        CC["Channel Classification"]:::processing
    end

    subgraph "Manifest Management"
        IM["Incremental Manifest"]:::manifest
        MC["Manifest Configuration"]:::manifest
    end

    subgraph "Core Attribution Models"
        PTC["Paths to Conversion"]:::output
        CCA["Campaign Attribution"]:::output
        CHA["Channel Attribution"]:::output
        AO["Attribution Overview"]:::output
    end

    subgraph "Optional Reporting"
        PS["Path Summary"]:::optional
        NCP["Non-Conversion Paths"]:::optional
    end

    %% Relationships
    UV --> PT
    CD --> PT
    MS -.-> PT
    PT --> UDF
    UDF --> TF
    TF --> TP
    CC --> TF
    TP --> PTC
    TP --> CCA
    TP --> CHA
    CCA --> AO
    CHA --> AO
    PTC --> PS
    PTC --> NCP
    IM --> PT
    MC --> IM

    %% Click Events
    click PT "https://github.com/snowplow/dbt-snowplow-attribution/tree/main/macros/path_transformations/"
    click UDF "https://github.com/snowplow/dbt-snowplow-attribution/blob/main/macros/path_transformations/create_udfs.sql"
    click TF "https://github.com/snowplow/dbt-snowplow-attribution/blob/main/macros/path_transformations/path_transformation.sql"
    click TP "https://github.com/snowplow/dbt-snowplow-attribution/blob/main/macros/path_transformations/trim_long_path.sql"
    click CC "https://github.com/snowplow/dbt-snowplow-attribution/blob/main/macros/channel_classification.sql"
    click PTC "https://github.com/snowplow/dbt-snowplow-attribution/blob/main/models/snowplow_attribution_paths_to_conversion.sql"
    click CCA "https://github.com/snowplow/dbt-snowplow-attribution/blob/main/models/snowplow_attribution_campaign_attributions.sql"
    click CHA "https://github.com/snowplow/dbt-snowplow-attribution/blob/main/models/snowplow_attribution_channel_attributions.sql"
    click AO "https://github.com/snowplow/dbt-snowplow-attribution/blob/main/models/snowplow_attribution_overview.sql"
    click PS "https://github.com/snowplow/dbt-snowplow-attribution/blob/main/models/optional_reporting/snowplow_attribution_path_summary.sql"
    click NCP "https://github.com/snowplow/dbt-snowplow-attribution/blob/main/models/optional_reporting/snowplow_attribution_paths_to_non_conversion.sql"
    click IM "https://github.com/snowplow/dbt-snowplow-attribution/blob/main/models/manifest/snowplow_attribution_incremental_manifest.sql"
    click MC "https://github.com/snowplow/dbt-snowplow-attribution/blob/main/models/manifest/manifest.yml"
    click UV "https://github.com/snowplow/dbt-snowplow-attribution/blob/main/integration_tests/models/source/default/snowplow_unified_events_stg.sql"
    click MS "https://github.com/snowplow/dbt-snowplow-attribution/blob/main/integration_tests/models/source/spend_source.sql"

    %% Styling
    classDef source fill:#3498db,stroke:#2980b9,color:white
    classDef source_optional fill:#9b59b6,stroke:#8e44ad,color:white
    classDef processing fill:#2ecc71,stroke:#27ae60,color:white
    classDef manifest fill:#e74c3c,stroke:#c0392b,color:white
    classDef output fill:#f1c40f,stroke:#f39c12,color:black
    classDef optional fill:#e67e22,stroke:#d35400,color:white

    %% Legend
    subgraph Legend
        L1["Data Sources"]:::source
        L2["Optional Sources"]:::source_optional
        L3["Processing"]:::processing
        L4["Manifest"]:::manifest
        L5["Core Models"]:::output
        L6["Optional Models"]:::optional
    end
```
