# gokul-krishnan-rudramurthy/dbt-airflow-poc architecture

> Architecture diagram of the GitHub repository gokul-krishnan-rudramurthy/dbt-airflow-poc, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-08-16). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/gokul-krishnan-rudramurthy/dbt-airflow-poc
- Repository: https://github.com/gokul-krishnan-rudramurthy/dbt-airflow-poc

## Overview

#### Purpose and boundaries
This repository is the Airflow orchestration half of a dbt proof of concept. It replaces a single scheduled `dbt run` pipeline step with an Airflow/Cosmos DAG that renders dbt seeds, models, and tests as observable tasks. The dbt project is intentionally external: a sibling `dbt-warehouse-model` repository is mounted into the runtime and remains free of Airflow code.

Core boundary paths: `dags/dbt_warehouse_poc_dag.py`, `docker-compose.yml`, `profiles/profiles.yml`.

#### Primary entry points
- Airflow loads and schedules the `dbt_warehouse_poc` DAG from `dags/dbt_warehouse_poc_dag.py`.
- Local environment lifecycle is driven through Docker Compose: initialize Airflow, then start its services via `docker-compose.yml`.
- `tools/view_data.py` is an on-demand host-side inspection entry point for the generated DuckDB file; it is not part of orchestration.

#### DAG rendering and execution
The DAG uses astronomer-cosmos `DbtDag` to parse the mounted external dbt project and convert dbt graph nodes into Airflow tasks. Seeds and models become individually retryable/logged tasks; dbt tests are configured as a combined project test task. Dependencies in the Airflow graph follow dbt model lineage.

The POC selects Cosmos local execution: dbt runs in the Airflow container rather than in an isolated worker, virtualenv, Docker, or Kubernetes runtime.

Path: `dags/dbt_warehouse_poc_dag.py`.

#### dbt project integration boundary
The DAG targets a fixed project mount point corresponding to `../dbt-warehouse-model` on the host. Compose supplies that repository as a read-only sibling bind mount, enabling independently versioned platform/orchestration and data-model repositories. In production, this mount contract can be preserved while replacing the bind mount with git-sync, an init container, or a deployment artifact.

Path: `docker-compose.yml`, `dags/dbt_warehouse_poc_dag.py`.

#### Warehouse and profile layer
dbt is configured against a local DuckDB database file, standing in for Snowflake and avoiding cloud credentials. The static dbt profile, rather than an Airflow connection, owns the target because DuckDB is file-backed. The persistent host-mounted warehouse file is expected under `warehouse_data/analytics.duckdb` (generated/ignored rather than represented in this tree).

Path: `profiles/profiles.yml`, `tools/view_data.py`.

#### Runtime and infrastructure
Docker Compose runs the local Airflow stack and exposes the Airflow UI on port 8081. The custom image installs Airflow-compatible Cosmos and dbt DuckDB dependencies; dependency declarations and image assembly are centralized in `requirements.txt` and `Dockerfile`. Environment variables are supplied through the local environment pattern represented by `.env.example`.

Paths: `Dockerfile`, `docker-compose.yml`, `requirements.txt`.

#### Production evolution points
The DAG graph and external-project contract are designed to survive a warehouse migration: replace the DuckDB adapter/profile with Snowflake credentials, preferably via Airflow connection/profile mapping plus a secrets backend. For scale and dependency isolation, move Cosmos execution from local mode to virtualenv, Docker, or Kubernetes and use a scalable Airflow executor or managed Airflow service. Deployment concerns—DAG distribution, dbt-project retrieval, secrets, scheduling, and alerts—are intentionally outside the dbt project boundary.

Paths: `dags/dbt_warehouse_poc_dag.py`, `profiles/profiles.yml`, `docker-compose.yml`.

Main entry points: [`dags/dbt_warehouse_poc_dag.py`](https://github.com/gokul-krishnan-rudramurthy/dbt-airflow-poc/blob/main/dags/dbt_warehouse_poc_dag.py) (Cosmos DbtDag), [`docker-compose.yml`](https://github.com/gokul-krishnan-rudramurthy/dbt-airflow-poc/blob/main/docker-compose.yml) (Docker Compose), [`Dockerfile`](https://github.com/gokul-krishnan-rudramurthy/dbt-airflow-poc/blob/main/Dockerfile) (Custom Airflow image), [`profiles/profiles.yml`](https://github.com/gokul-krishnan-rudramurthy/dbt-airflow-poc/blob/main/profiles/profiles.yml) (DuckDB profile)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_local["Local Airflow Runtime"]
  node_compose{{"Docker Compose<br/>runtime definition<br/>[docker-compose.yml]"}}
  node_airflow["Airflow services<br/>orchestrator<br/>[docker-compose.yml]"]
  node_image["Custom Airflow image<br/>container image"]
  node_requirements["Python dependencies<br/>dependency manifest<br/>[requirements.txt]"]
  node_env["Local environment<br/>environment template<br/>[.env.example]"]
end

subgraph group_dag["DAG and dbt Execution"]
  node_dag_file["dbt_warehouse_poc DAG<br/>Airflow DAG"]
  node_cosmos["Cosmos DbtDag<br/>DAG renderer"]
  node_seed_tasks["Seed tasks<br/>dbt task group"]
  node_model_tasks["Model tasks<br/>dbt task group"]
  node_test_task["Project test task<br/>dbt task"]
end

subgraph group_data["External Model and Warehouse"]
  node_dbt_project["External dbt project<br/>sibling repository"]
  node_profile["DuckDB profile<br/>dbt profile<br/>[profiles.yml]"]
  node_duckdb[("analytics.duckdb<br/>warehouse file")]
  node_viewer["Data viewer<br/>host-side CLI<br/>[view_data.py]"]
end

node_requirements -->|"installed into"| node_image
node_image -->|"runs"| node_airflow
node_env -.->|"configures"| node_compose
node_compose -->|"starts"| node_airflow
node_compose -->|"read-only sibling mount"| node_dbt_project
node_compose -->|"persistent host mount"| node_duckdb
node_airflow -->|"loads and schedules"| node_dag_file
node_dag_file -->|"defines"| node_cosmos
node_cosmos -->|"parses"| node_dbt_project
node_cosmos -->|"renders"| node_seed_tasks
node_cosmos -->|"renders"| node_model_tasks
node_cosmos -->|"renders"| node_test_task
node_seed_tasks -->|"dbt lineage"| node_model_tasks
node_model_tasks -->|"tests modeled data"| node_test_task
node_profile -->|"targets"| node_duckdb
node_cosmos -->|"uses local execution profile"| node_profile
node_model_tasks -->|"writes models"| node_duckdb
node_seed_tasks -->|"loads seeds"| node_duckdb
node_test_task -->|"queries"| node_duckdb
node_viewer -.->|"inspects on demand"| node_duckdb

click node_compose "https://github.com/gokul-krishnan-rudramurthy/dbt-airflow-poc/blob/main/docker-compose.yml"
click node_airflow "https://github.com/gokul-krishnan-rudramurthy/dbt-airflow-poc/blob/main/docker-compose.yml"
click node_image "https://github.com/gokul-krishnan-rudramurthy/dbt-airflow-poc/blob/main/Dockerfile"
click node_requirements "https://github.com/gokul-krishnan-rudramurthy/dbt-airflow-poc/blob/main/requirements.txt"
click node_env "https://github.com/gokul-krishnan-rudramurthy/dbt-airflow-poc/blob/main/.env.example"
click node_dag_file "https://github.com/gokul-krishnan-rudramurthy/dbt-airflow-poc/blob/main/dags/dbt_warehouse_poc_dag.py"
click node_cosmos "https://github.com/gokul-krishnan-rudramurthy/dbt-airflow-poc/blob/main/dags/dbt_warehouse_poc_dag.py"
click node_seed_tasks "https://github.com/gokul-krishnan-rudramurthy/dbt-airflow-poc/blob/main/dags/dbt_warehouse_poc_dag.py"
click node_model_tasks "https://github.com/gokul-krishnan-rudramurthy/dbt-airflow-poc/blob/main/dags/dbt_warehouse_poc_dag.py"
click node_test_task "https://github.com/gokul-krishnan-rudramurthy/dbt-airflow-poc/blob/main/dags/dbt_warehouse_poc_dag.py"
click node_profile "https://github.com/gokul-krishnan-rudramurthy/dbt-airflow-poc/blob/main/profiles/profiles.yml"
click node_viewer "https://github.com/gokul-krishnan-rudramurthy/dbt-airflow-poc/blob/main/tools/view_data.py"

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_compose,node_airflow,node_image,node_requirements,node_env toneBlue
class node_dag_file,node_cosmos,node_seed_tasks,node_model_tasks,node_test_task toneAmber
class node_dbt_project,node_profile,node_duckdb,node_viewer toneMint
```

## Components

### Local Airflow Runtime

Compose-managed orchestration environment.

- [Docker Compose](https://github.com/gokul-krishnan-rudramurthy/dbt-airflow-poc/blob/main/docker-compose.yml): runtime definition · Initializes and starts the local Airflow stack with mounts. · `docker-compose.yml`
- [Airflow services](https://github.com/gokul-krishnan-rudramurthy/dbt-airflow-poc/blob/main/docker-compose.yml): orchestrator · Schedules DAGs and exposes the UI on port 8081. · `docker-compose.yml`
- [Custom Airflow image](https://github.com/gokul-krishnan-rudramurthy/dbt-airflow-poc/blob/main/Dockerfile): container image · Provides the Airflow runtime with Cosmos and dbt dependencies. · `Dockerfile`
- [Python dependencies](https://github.com/gokul-krishnan-rudramurthy/dbt-airflow-poc/blob/main/requirements.txt): dependency manifest · Declares Airflow-compatible Cosmos and dbt-duckdb packages. · `requirements.txt`
- [Local environment](https://github.com/gokul-krishnan-rudramurthy/dbt-airflow-poc/blob/main/.env.example): environment template · Supplies local runtime variables. · `.env.example`

### DAG and dbt Execution

Cosmos renders and runs the external dbt graph.

- [dbt_warehouse_poc DAG](https://github.com/gokul-krishnan-rudramurthy/dbt-airflow-poc/blob/main/dags/dbt_warehouse_poc_dag.py): Airflow DAG · Main scheduled orchestration entry point. · `dags/dbt_warehouse_poc_dag.py`
- [Cosmos DbtDag](https://github.com/gokul-krishnan-rudramurthy/dbt-airflow-poc/blob/main/dags/dbt_warehouse_poc_dag.py): DAG renderer · Parses the dbt project and materializes its lineage as Airflow tasks. · `dags/dbt_warehouse_poc_dag.py`
- [Seed tasks](https://github.com/gokul-krishnan-rudramurthy/dbt-airflow-poc/blob/main/dags/dbt_warehouse_poc_dag.py): dbt task group · Individually observable and retryable seed executions. · `dags/dbt_warehouse_poc_dag.py`
- [Model tasks](https://github.com/gokul-krishnan-rudramurthy/dbt-airflow-poc/blob/main/dags/dbt_warehouse_poc_dag.py): dbt task group · Individually observable and retryable model executions following dbt lineage. · `dags/dbt_warehouse_poc_dag.py`
- [Project test task](https://github.com/gokul-krishnan-rudramurthy/dbt-airflow-poc/blob/main/dags/dbt_warehouse_poc_dag.py): dbt task · Runs dbt tests as one combined project task. · `dags/dbt_warehouse_poc_dag.py`

### External Model and Warehouse

Independently versioned dbt project and local warehouse.

- **External dbt project**: sibling repository · Read-only mounted data-model repository with no Airflow code.
- [DuckDB profile](https://github.com/gokul-krishnan-rudramurthy/dbt-airflow-poc/blob/main/profiles/profiles.yml): dbt profile · Static file-backed warehouse target owned by dbt. · `profiles/profiles.yml`
- **analytics.duckdb**: warehouse file · Persistent host-mounted local analytical warehouse.
- [Data viewer](https://github.com/gokul-krishnan-rudramurthy/dbt-airflow-poc/blob/main/tools/view_data.py): host-side CLI · On-demand inspection of the generated DuckDB file; outside orchestration. · `tools/view_data.py`

## Connections

- Python dependencies → Custom Airflow image: installed into
- Custom Airflow image → Airflow services: runs
- Local environment → Docker Compose: configures
- Docker Compose → Airflow services: starts
- Docker Compose → External dbt project: read-only sibling mount
- Docker Compose → analytics.duckdb: persistent host mount
- Airflow services → dbt_warehouse_poc DAG: loads and schedules
- dbt_warehouse_poc DAG → Cosmos DbtDag: defines
- Cosmos DbtDag → External dbt project: parses
- Cosmos DbtDag → Seed tasks: renders
- Cosmos DbtDag → Model tasks: renders
- Cosmos DbtDag → Project test task: renders
- Seed tasks → Model tasks: dbt lineage
- Model tasks → Project test task: tests modeled data
- DuckDB profile → analytics.duckdb: targets
- Cosmos DbtDag → DuckDB profile: uses local execution profile
- Model tasks → analytics.duckdb: writes models
- Seed tasks → analytics.duckdb: loads seeds
- Project test task → analytics.duckdb: queries
- Data viewer → analytics.duckdb: inspects on demand
