# calogica/dbt-date architecture

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

- Interactive diagram: https://gitdiagram.com/calogica/dbt-date
- Repository: https://github.com/calogica/dbt-date

## Overview

dbt-date is a dbt macro package for cross-database date and calendar logic. A project model invokes its macros to generate date spines, date dimensions, fiscal calendars, or individual date expressions. The README documents the date-dimension-to-fiscal-calendar use and the date-spine dependency; other macro internals are not shown, so no additional call relationships are inferred.

Main entry points: [`macros/get_base_dates.sql`](https://github.com/calogica/dbt-date/blob/main/macros/get_base_dates.sql) (Base date spine), [`macros/get_date_dimension.sql`](https://github.com/calogica/dbt-date/blob/main/macros/get_date_dimension.sql) (Date dimension), [`macros/fiscal_date/get_fiscal_periods.sql`](https://github.com/calogica/dbt-date/blob/main/macros/fiscal_date/get_fiscal_periods.sql) (Fiscal periods), [`macros/calendar_date`](https://github.com/calogica/dbt-date/tree/main/macros/calendar_date) (Date parts)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_generation["Calendar generation"]
  node_base_dates["Base date spine<br/>[get_base_dates.sql]"]
  node_date_dimension["Date dimension"]
  node_date_spine_utils["Spine utilities"]
end

subgraph group_calendar["Calendar expressions"]
  node_calendar_parts["Date parts"]
  node_calendar_periods["Relative periods"]
  node_calendar_weeks["Week calculations"]
  node_calendar_timezone["Timezone and epochs"]
end

subgraph group_fiscal["Fiscal calendars"]
  node_fiscal_periods["Fiscal periods"]
  node_fiscal_year_dates["Fiscal year dates"]
end

subgraph group_utilities["Date utilities"]
  node_datetime_utils["Date and datetime"]
end

node_model_author(("dbt project model"))
node_dbt_utils["dbt-utils"]

node_model_author -->|"invokes"| node_base_dates
node_model_author -->|"invokes"| node_date_dimension
node_model_author -->|"invokes"| node_fiscal_periods
node_model_author -->|"invokes"| node_calendar_parts
node_model_author -->|"invokes"| node_calendar_periods
node_model_author -->|"invokes"| node_calendar_weeks
node_model_author -->|"invokes"| node_calendar_timezone
node_model_author -->|"invokes"| node_datetime_utils
node_base_dates -->|"wraps date_spine"| node_dbt_utils
node_date_dimension -->|"provides dates"| node_fiscal_periods

click node_base_dates "https://github.com/calogica/dbt-date/blob/main/macros/get_base_dates.sql"
click node_date_dimension "https://github.com/calogica/dbt-date/blob/main/macros/get_date_dimension.sql"
click node_date_spine_utils "https://github.com/calogica/dbt-date/tree/main/macros/_utils"
click node_calendar_parts "https://github.com/calogica/dbt-date/tree/main/macros/calendar_date"
click node_calendar_periods "https://github.com/calogica/dbt-date/tree/main/macros/calendar_date"
click node_calendar_weeks "https://github.com/calogica/dbt-date/tree/main/macros/calendar_date"
click node_calendar_timezone "https://github.com/calogica/dbt-date/tree/main/macros/calendar_date"
click node_fiscal_periods "https://github.com/calogica/dbt-date/blob/main/macros/fiscal_date/get_fiscal_periods.sql"
click node_fiscal_year_dates "https://github.com/calogica/dbt-date/blob/main/macros/fiscal_date/get_fiscal_year_dates.sql"
click node_datetime_utils "https://github.com/calogica/dbt-date/blob/main/macros/_utils/modules_datetime.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_base_dates,node_date_dimension,node_date_spine_utils toneBlue
class node_calendar_parts,node_calendar_periods,node_calendar_weeks,node_calendar_timezone toneAmber
class node_fiscal_periods,node_fiscal_year_dates toneMint
class node_datetime_utils toneRose
class node_model_author,node_dbt_utils toneIndigo
```

## Components

### Calendar generation

- [Base date spine](https://github.com/calogica/dbt-date/blob/main/macros/get_base_dates.sql): `macros/get_base_dates.sql`
- [Date dimension](https://github.com/calogica/dbt-date/blob/main/macros/get_date_dimension.sql): `macros/get_date_dimension.sql`
- [Spine utilities](https://github.com/calogica/dbt-date/tree/main/macros/_utils): `macros/_utils`

### Calendar expressions

- [Date parts](https://github.com/calogica/dbt-date/tree/main/macros/calendar_date): `macros/calendar_date`
- [Relative periods](https://github.com/calogica/dbt-date/tree/main/macros/calendar_date): `macros/calendar_date`
- [Week calculations](https://github.com/calogica/dbt-date/tree/main/macros/calendar_date): `macros/calendar_date`
- [Timezone and epochs](https://github.com/calogica/dbt-date/tree/main/macros/calendar_date): `macros/calendar_date`

### Fiscal calendars

- [Fiscal periods](https://github.com/calogica/dbt-date/blob/main/macros/fiscal_date/get_fiscal_periods.sql): `macros/fiscal_date/get_fiscal_periods.sql`
- [Fiscal year dates](https://github.com/calogica/dbt-date/blob/main/macros/fiscal_date/get_fiscal_year_dates.sql): `macros/fiscal_date/get_fiscal_year_dates.sql`

### Date utilities

- [Date and datetime](https://github.com/calogica/dbt-date/blob/main/macros/_utils/modules_datetime.sql): `macros/_utils/modules_datetime.sql`

### Other components

- **dbt project model**
- **dbt-utils**

## Connections

- dbt project model → Base date spine: invokes (evidence: `README.md`)
- dbt project model → Date dimension: invokes (evidence: `README.md`)
- dbt project model → Fiscal periods: invokes (evidence: `README.md`)
- dbt project model → Date parts: invokes (evidence: `README.md`)
- dbt project model → Relative periods: invokes (evidence: `README.md`)
- dbt project model → Week calculations: invokes (evidence: `README.md`)
- dbt project model → Timezone and epochs: invokes (evidence: `README.md`)
- dbt project model → Date and datetime: invokes (evidence: `README.md`)
- Base date spine → dbt-utils: wraps date_spine (evidence: `README.md`)
- Date dimension → Fiscal periods: provides dates (evidence: `README.md`)
