Lab build

Airflow ETL for NASA APOD into Postgres

Daily Airflow DAG that pulls NASA's Astronomy Picture of the Day and loads it into Postgres.

Role
Builder, end to end
Group
MLOps
Services
MLOps & cloud

What it does

An Airflow DAG on the Astro runtime creates an apod_data table, calls the NASA APOD API through an HTTP connection, keeps the title, explanation, URL, date and media type, and inserts the row with a Postgres hook. Postgres runs in Docker Compose for local runs; the DAG is deployed to Astronomer's Astro cloud against a Postgres database on AWS RDS.

What was built

  1. 01

    create_table task issues CREATE TABLE IF NOT EXISTS for apod_data through PostgresHook.

  2. 02

    SimpleHttpOperator calls planetary/apod with the API key stored in the Airflow connection extras.

  3. 03

    TaskFlow transform keeps five fields; a load task inserts them with a parameterised query.

  4. 04

    DAG runs @daily without catchup, locally through the Astro CLI and in Astro cloud.

The pipeline, layer by layer

Five layers, one pipeline.

  1. L1Schedule

    • Airflow @daily DAG
  2. L2Extract

    • NASA APOD API
  3. L3Transform

    • TaskFlow transform
  4. L4Load

    • Postgres load task
    • PostgreSQL on AWS RDS
  5. L5Platform

    • Astro cloud deployment

Stack

  • Apache Airflow
  • Astronomer Astro
  • PostgreSQL
  • PostgresHook
  • SimpleHttpOperator
  • NASA APOD API
  • Docker Compose
  • AWS RDS

Next lab build · 28 / 46

Transaction monitoring dashboard in Grafana

Writes rule-scored synthetic card transactions to Postgres on AWS and charts approvals in Grafana Cloud.

Previous: MovieLens recommender evaluation framework

Need a system like this in production? Tell us about it.