Onboarding Guide: treetracker-airflow-dags

Generated from the Understand-Anything knowledge graph. Source commit a537231.

Project Overview

treetracker-airflow-dags is Greenstand's Apache Airflow automation pipeline for the Tree Tracker platform. Python DAGs schedule and trigger recurring data jobs (export, migration, reporting/analytics, web-map precompute, and species identification) while a shared lib/ holds the reusable job logic. A few jobs also run as Node.js scripts driven by shell/cron wrappers.

Core pattern: DAG files stay thin. A *_dag.py wires an Airflow PythonOperator to a callable that lives in lib/; the real work (SQL, CSV export, uploads) is in the library module. Learn one DAG and you understand them all.

Architecture Layers

Key Concepts

Guided Tour

  1. Project Overview: Read the README for what the repo automates and how it is deployed.
  2. The DAG Orchestration Pattern: earnings_export_dag.py: a thin DAG wiring a PythonOperator to a lib callable.
  3. Shared Utilities (lib/utils): the most-depended-upon file: date/DB helpers + failure callback.
  4. An Export Job (lib/earning_export): the real work behind Step 2: query, build CSV, upload.
  5. A Reporting Job with PostGIS: lib/country_leader_board.py: spatial SQL for per-country counts.
  6. A Migration Job: migrate_stakeholders_dag.py: reshaping/consolidating data.
  7. Web-Map Precompute DAGs: pre_request_map_clusters_dag.py: cache-warming for the map.
  8. Map Node.js Scripts: map/tile-pre-cache.py shelling out to Node precompute scripts.
  9. Cron & Shell Wrappers: running the Node map scripts as cron jobs with PID locking.
  10. The Test Approach: pytest covers lib/ job logic, not the thin DAGs.

Complexity Hotspots

Approach carefully (45 files rated moderate+):


Regenerate with /understand then /understand-domain then /understand-onboard. See docs/regenerating.md in the docs repo.