Skip to content
ndataopsPublic

About

Production-grade bioacoustic monitoring lakehouse: BirdNET-Go + dbt + Dagster + Databricks (Unity Catalog) + Evidence.dev, running on a two-node home network

Topics

Resources

Stars

1 star

Watchers

0 watching

Forks

Repository files navigation

Birdbox

dbt build License: MIT Last commit

A production-grade bioacoustic monitoring lakehouse running on a two-node home network — built to demonstrate end-to-end data engineering (ingestion, orchestration, transformation, and a live analytics dashboard, all running unattended) with genuine species detection enriched via eBird's taxonomy API.

Note on citizen science integrations: BirdNET-Go supports submitting detections to BirdWeather, but this requires uploading raw audio clips, and BirdWeather has no mechanism to submit detection metadata without the associated recording. After evaluating the privacy tradeoff, that integration is intentionally disabled here — this project prioritizes not capturing/sharing ambient audio over the citizen-science contribution. eBird's API is used read-only for species taxonomy lookups (no audio, no data leaves the device beyond the lookup query itself).

Live demo: birdbox.tail69334c.ts.net Repo: github.com/ndataops/birdbox Incident log: docs/incidents.md - deeper write-ups of the bugs below

Birdbox dashboard

Birdbox architecture

The physical build

Before Wired Deployed
Parts Internals Mounted

Raspberry Pi 4, condenser mic, IP54 weatherproof enclosure, mounted on a rooftop railing. Full build story, hardware decisions, and how it ties into the reliability work: docs/build.md.

What it does

A Raspberry Pi in a weatherproof rooftop enclosure (birdedge) runs BirdNET-Go against a shotgun microphone to detect and identify bird species from live audio, alongside a BME280 sensor logging temperature, humidity, and pressure. A Lenovo ThinkCentre (birdbox) on the same network pulls that data on a schedule and, every 3 hours, pushes it to Databricks, where dbt builds bronze/silver/gold Delta tables in Unity Catalog. A live dashboard, the "Field Journal," reads from the gold layer.

Everything (the sensor syncs, the Databricks refresh, the dashboard rebuild, even this README's stats) runs on Dagster schedules with no manual intervention. The stack recovers from a power outage on its own: the machine powers back on, systemd restarts every service, and an external heartbeat raises an alert if it doesn't.

Stack

  • Ingestion: BirdNET-Go, BME280 (I2C), MinIO (S3-compatible object storage)
  • Lakehouse: Databricks Free Edition: Unity Catalog, Delta tables, serverless SQL warehouse
  • Transformation: dbt-databricks, bronze/silver/gold medallion, data tests including an automated freshness check
  • Orchestration: Dagster (asset-based; 5- and 10-minute ingestion, 3-hourly Databricks refresh)
  • Dashboards: Evidence.dev static production build (public demo); Databricks AI/BI dashboard on a Unity Catalog metric view
  • Infra & ops: systemd, Tailscale Funnel (public HTTPS demo), GitHub Actions CI, Healthchecks.io heartbeat, Discord alerting
  • Languages: Python, SQL (Databricks SQL)

Live stats

  • Detections: 16,820
  • Species identified: 150
  • Latest detection: 2026-12-06 11:05 CT
  • Telemetry readings: 25,191
  • Last updated: 2026-12-06 18:00 UTC (auto-generated every 3 hours from Databricks)

Architecture

flowchart LR
  subgraph edge["birdedge: Raspberry Pi 4, rooftop"]
    mic["Shotgun mic + BirdNET-Go"] --> det[("detections SQLite")]
    bme["BME280 sensor"] --> tel[("telemetry SQLite")]
  end
  subgraph box["birdbox: ThinkCentre M720q"]
    minio[("MinIO")]
    snap[("bronze snapshots")]
    ev["Evidence.dev Field Journal"]
  end
  subgraph dbx["Databricks: Unity Catalog birdbox"]
    vol[("UC volume")] --> b["bronze Delta"] --> s["silver"] --> g["gold"]
  end
  det -- "rclone, every minute" --> minio
  minio -- "bronze_birdnet_sync, 10 min" --> snap
  tel -- "snapshot push, 5 min" --> minio
  minio -- "bronze_telemetry_sync, 5 min" --> snap
  snap -- "every 3 hours: export, upload, MERGE, dbt build" --> vol
  g --> ev
  g --> readme["README live stats"]
  ev -- "Tailscale Funnel" --> pub(("Public dashboard"))
Loading

Medallion layers in Unity Catalog (birdbox catalog):

  • Bronze: raw Delta tables loaded from birdedge snapshots (BirdNET-Go detections and BME280 readings, both via MinIO). Detections and telemetry are upserted with MERGE (see Operations); the small reference tables are replaced.
  • Silver: cleaned, deduplicated, typed (int_bird_detections_cleaned, int_telemetry_cleaned)
  • Gold: analytics-ready facts (fct_bird_detections, fct_detections_with_weather, a nearest-15-minute join between detections and enclosure readings)

Timestamps stay in UTC through bronze and silver. Conversion to Chicago time happens only in gold.

Orchestration, all Dagster-scheduled:

  • bronze_telemetry_sync: every 5 minutes
  • bronze_birdnet_sync: every 10 minutes, pulling from MinIO
  • databricks_job: every 3 hours at :07. databricks_refresh (export, upload to a UC volume, MERGE into bronze Delta, dbt build), then evidence_build, then update_readme
  • backup_job: daily snapshot backups

The original DuckDB implementation remains in dbt-project/ as a rollback path until it's retired.

Engineering practices

  • CI on every pull request: GitHub Actions runs dbt build (models, seed and 28 data tests) against Databricks in an isolated per-PR schema (ci_pr_<n>_*) and drops it afterward. The live-sensor freshness test runs against production instead, since it depends on current data. A custom generate_schema_name macro keeps CI writes out of production schemas.
  • Incremental model: fct_detections_with_weather is a dbt incremental model using the merge strategy on detection_id, with a 2-day lookback to absorb late-arriving sensor readings and backfilled detections. CI re-runs it and asserts the row count and checksum are unchanged.
  • Metric layer: databricks/metric_views/mv_detections.sql defines the KPIs (detection count, distinct species, high-confidence rate, average confidence, average enclosure temperature) once as a Unity Catalog metric view. The Databricks AI/BI dashboard queries it with MEASURE().

Incidents found and fixed

Full write-ups are in docs/incidents.md and docs/lessons-learned.md.

  • Unbounded cron stacking. A * * * * * rclone sync had no lock protection; overlapping runs piled up and exhausted memory/CPU on the Pi, taking it offline. Fixed with flock-guarded cron.
  • Silent 6-day pipeline outage. After moving Dagster to systemd, dbt resolved by bare name on $PATH — which worked in an interactive shell but not under systemd's minimal environment. The entire dbt layer silently stopped running; nobody noticed until a downstream chart came up empty. Fixed with an explicit executable path.
  • A pipeline that never existed. Bird detection sync from birdedge to the lakehouse had no automation at all — a one-time manual copy from early setup, never turned into a scheduled asset. Built a proper bronze_birdnet_sync asset pulling from MinIO, matching the existing medallion pattern.
  • Plaintext credentials in two places. A MinIO secret was hardcoded in both profiles.yml and docker-compose.yml. Replaced with env_var()/${VAR} substitution backed by a single chmod 600 secrets file — zero plaintext credentials anywhere in the codebase or git history.
  • A disk filled by build artifacts. The dashboard went stale for about a week when the root disk hit 100%. The Evidence build step was merging hash-named output into the previous build without clearing it (47G vs. a ~115M clean build). Recovered with no data loss, because birdedge buffered the backlog.
  • A weather join off by ~10 hours. A time zone conversion applied to an already-naive UTC timestamp shifted telemetry, so each detection was paired with readings from the middle of the night. Found by checking a gold row against raw sensor data, and fixed in the Databricks port with a rule: UTC until gold. The same check revealed the sensor reads enclosure temperature, not ambient, so it was relabeled.
  • A migration near-miss. A failed cd let the rest of a command block write ~20 Databricks-port files into the live dbt project. Git showed the full blast radius, and it was restored with live data verified intact. The fix: chain dependent commands with &&, and experiment in a verified copy.
  • Eight silent days after a power cut. The host lost power, stayed off due to a BIOS default, and nothing alerted, because failure alerts ran on the host itself. Fixed with auto power-on, retries, and an external heartbeat (see Operations).
  • A weak Wi-Fi uplink hidden behind healthy checks. telemetry_job failed every run overnight because a synchronous scp from the Pi stalled on its rooftop Wi-Fi, even though ping, MTU, and SSH all looked fine. Isolated by testing each layer and direction separately, then replaced the pull with store-and-forward: the Pi pushes a consistent SQLite snapshot to the bucket every 5 minutes, and the hub validates it and swaps it in atomically. No gap in the data.
  • Recurring Databricks provisioning failures. Three times in about two weeks (Oct 19, Oct 30, Nov 5) the serverless warehouse stopped and refused to restart (Cannot create the resource), outlasting the retry policy. The Healthchecks.io heartbeat caught each one, and no data was lost because birdedge kept buffering. The root cause (Free Edition quota vs. capacity) is unconfirmed, so as an experiment the refresh moved from hourly to every 3 hours to cut warehouse wake-ups. Follow-ups: a warm-up query and a gold freshness alert.
  • A tripped outlet, and no monitoring of the edge device itself. A GFCI outlet cut power to the Pi overnight (13 hours of sensor readings lost). The pipeline failed fast with a clear error and the dbt freshness test blocked builds on stale data, but nothing watched the Pi directly, so the outage showed up only through downstream failures. Verified recovery (clock sync, services, data), then added a success-only heartbeat from the Pi so a dead edge device alerts within about half an hour.

Operations

  • Self-healing: BIOS set to power on after an outage; every service runs under systemd. Verified with a deliberate reboot: services, schedules, and the next Databricks refresh all recovered with no intervention.
  • Retries: databricks_refresh retries up to 3 times with exponential backoff (1, 2, 4 minutes), riding out serverless cold starts and short capacity blips on Free Edition. A multi-hour outage is covered by the next scheduled run and the heartbeat alert.
  • Alerting, three layers: a Dagster sensor posts failed runs to Discord; each successful databricks_job run pings a Healthchecks.io heartbeat (period 3 hours, 1 hour grace), which alerts after about 4 hours of silence (host down, or Databricks failing repeatedly); and the Pi pings its own heartbeat after every successful telemetry sync (period 10 minutes, 20 minutes grace), so a dead edge device alerts within about half an hour.
  • Durability: birdedge buffers detections locally and syncs every minute, so a birdbox outage delays data rather than losing it.
  • Idempotent loads: detections and raw_telemetry are loaded into bronze with MERGE INTO on a stable key (detection id, reading timestamp). Unchanged rows are left alone, changed rows are updated, and rows missing from the snapshot are deleted, so a rerun is a no-op. The source is deduplicated first, an empty or truncated snapshot (under 90% of current rows) is refused before the delete clause can run, and changes are detected with null-safe comparison. Verified by breaking a clone on purpose (missing rows, a changed value, a fake row) and checking each run repaired exactly that, then confirming a rerun changed nothing. A run with five new detections wrote five rows (about 4.7 KB) instead of rewriting the table (about 286 KB).

Skills demonstrated

  • Orchestration: Dagster (asset-based scheduling, sensors, run-failure alerting)
  • Transformation & data quality: dbt (medallion architecture, 29 data tests, enforced data contracts, incremental merge models, freshness checks)
  • CI/CD: GitHub Actions on every PR: dbt parse, ruff linting of the Dagster pipeline, and a full dbt build with tests against Databricks in an isolated per-PR schema, plus a re-run check that the incremental model is idempotent
  • Infrastructure reliability: systemd service supervision, automated backups, reboot-tested on real hardware
  • Observability: Discord failure alerting, self-updating documentation, Healthchecks.io heartbeat
  • Data engineering judgment: root-caused multiple production incidents, made and documented a privacy-vs-feature tradeoff decision
  • Full-stack delivery: live public dashboard (Evidence.dev), interactive data catalog (dbt docs), physical IoT hardware
  • Cloud lakehouse: Databricks (Unity Catalog, Delta, serverless SQL), migrated from DuckDB with parity verification; idempotent MERGE loads tested for insert, update, delete, and rerun
  • Semantic layer & BI: Unity Catalog metric views defining the KPIs once, with a Databricks AI/BI dashboard built on them

Roadmap

  • Declarative deployment with Databricks Asset Bundles and Unity Catalog grants
  • Retire the DuckDB rollback path
  • Natural-language query layer over the lakehouse
  • Reusable "lakehouse spine" for sibling projects (air quality, transit, pollinators)

Running it locally

git clone https://github.com/ndataops/birdbox.git
cd birdbox

# dbt
cd dbt-project && dbt build

# Dagster
cd ../birdbox_pipeline && dagster dev

# Dashboard
cd ../field-journal && npm install && npm run sources && npm run build && npm run preview

Requires exported MINIO_ACCESS_KEY, MINIO_SECRET_KEY for the MinIO-backed assets, and EBIRD_API_KEY for the taxonomy sync (free key at ebird.org/api/keygen).

About

Built by Nelson Schicke — LinkedIn

About

Production-grade bioacoustic monitoring lakehouse: BirdNET-Go + dbt + Dagster + Databricks (Unity Catalog) + Evidence.dev, running on a two-node home network

Topics

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages