How gokul-krishnan-rudramurthy/dbt-airflow-poc works
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: dbt_warehouse_poc_dag.py Cosmos DbtDag · docker-compose.yml Docker Compose · Dockerfile Custom Airflow image · profiles.yml DuckDB profile
Components 14
Local Airflow Runtime
Compose-managed orchestration environment.
- Docker Compose · Initializes and starts the local Airflow stack with mounts.
docker-compose.yml - Airflow services · Schedules DAGs and exposes the UI on port 8081.
docker-compose.yml - Custom Airflow image · Provides the Airflow runtime with Cosmos and dbt dependencies.
Dockerfile - Python dependencies · Declares Airflow-compatible Cosmos and dbt-duckdb packages.
requirements.txt - Local environment · Supplies local runtime variables.
.env.example
DAG and dbt Execution
Cosmos renders and runs the external dbt graph.
- dbt_warehouse_poc DAG · Main scheduled orchestration entry point.
dags/dbt_warehouse_poc_dag.py - Cosmos DbtDag · Parses the dbt project and materializes its lineage as Airflow tasks.
dags/dbt_warehouse_poc_dag.py - Seed tasks · Individually observable and retryable seed executions.
dags/dbt_warehouse_poc_dag.py - Model tasks · Individually observable and retryable model executions following dbt lineage.
dags/dbt_warehouse_poc_dag.py - Project test 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 · Read-only mounted data-model repository with no Airflow code.
- DuckDB profile · Static file-backed warehouse target owned by dbt.
profiles/profiles.yml - analytics.duckdb · Persistent host-mounted local analytical warehouse.
- Data viewer · On-demand inspection of the generated DuckDB file; outside orchestration.
tools/view_data.py
Connections 20
- 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