# ponderedw/dbt_simple_metrics architecture

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

- Interactive diagram: https://gitdiagram.com/ponderedw/dbt_simple_metrics
- Repository: https://github.com/ponderedw/dbt_simple_metrics
- Video tour (about a minute): https://gitdiagram.com/ponderedw/dbt_simple_metrics/video

## Overview

`dbt_simple_metrics` is a dbt package that turns YAML metric definitions into reusable aggregate SQL. The principal workflow is to define metrics and dimensions, call `metrics`, and let dbt compile the query; `join_metrics` adds cross-model aggregation and entity-based join inference. The README documents these behaviors, but no source excerpts were provided, so internal helper calls and implementation details are not asserted.

Main entry points: [`macros/join.sql`](https://github.com/ponderedw/dbt_simple_metrics/blob/main/macros/join.sql) (Cross-model joins), [`macros/metrics.sql`](https://github.com/ponderedw/dbt_simple_metrics/blob/main/macros/metrics.sql) (Metric aggregation)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_definitions["Metric definitions"]
  node_metric_yaml["Model YAML"]
  node_semantic_yaml["Semantic models"]
end

subgraph group_generation["SQL generation"]
  node_metrics_macro["Metric aggregation<br/>[metrics.sql]"]
  node_join_macro["Cross-model joins<br/>[join.sql]"]
  node_utils_macro["SQL utilities<br/>[utils.sql]"]
end

subgraph group_execution["dbt execution"]
  node_dbt["dbt compiler"]
  node_warehouse[("Data warehouse")]
end

node_analyst(("Analytics author"))

node_analyst -->|"defines metrics"| node_metric_yaml
node_analyst -->|"defines entities"| node_semantic_yaml
node_dbt -->|"invokes macro"| node_metrics_macro
node_metric_yaml -->|"provides definitions"| node_metrics_macro
node_metrics_macro -->|"generates SQL"| node_dbt
node_dbt -->|"invokes macro"| node_join_macro
node_semantic_yaml -->|"guides join inference"| node_join_macro
node_metric_yaml -->|"provides metrics"| node_join_macro
node_join_macro -->|"generates SQL"| node_dbt
node_dbt -->|"runs SQL"| node_warehouse

click node_metrics_macro "https://github.com/ponderedw/dbt_simple_metrics/blob/main/macros/metrics.sql"
click node_join_macro "https://github.com/ponderedw/dbt_simple_metrics/blob/main/macros/join.sql"
click node_utils_macro "https://github.com/ponderedw/dbt_simple_metrics/blob/main/macros/utils.sql"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_metric_yaml,node_semantic_yaml toneBlue
class node_metrics_macro,node_join_macro,node_utils_macro toneAmber
class node_dbt,node_warehouse toneMint
class node_analyst toneIndigo
```

## Components

### Metric definitions

- **Model YAML**
- **Semantic models**

### SQL generation

- [Metric aggregation](https://github.com/ponderedw/dbt_simple_metrics/blob/main/macros/metrics.sql): `macros/metrics.sql`
- [Cross-model joins](https://github.com/ponderedw/dbt_simple_metrics/blob/main/macros/join.sql): `macros/join.sql`
- [SQL utilities](https://github.com/ponderedw/dbt_simple_metrics/blob/main/macros/utils.sql): `macros/utils.sql`

### dbt execution

- **dbt compiler**
- **Data warehouse**

### Other components

- **Analytics author**

## Connections

- Analytics author → Model YAML: defines metrics (evidence: `README.md`)
- Analytics author → Semantic models: defines entities (evidence: `README.md`)
- dbt compiler → Metric aggregation: invokes macro (evidence: `README.md`)
- Model YAML → Metric aggregation: provides definitions (evidence: `README.md`)
- Metric aggregation → dbt compiler: generates SQL (evidence: `README.md`)
- dbt compiler → Cross-model joins: invokes macro (evidence: `README.md`)
- Semantic models → Cross-model joins: guides join inference (evidence: `README.md`)
- Model YAML → Cross-model joins: provides metrics (evidence: `README.md`)
- Cross-model joins → dbt compiler: generates SQL (evidence: `README.md`)
- dbt compiler → Data warehouse: runs SQL (evidence: `README.md`)
