AskABird — Project Story
"From Habitat-Searching to Habitat-Saving: a Tucson story about looking up — and looking around."
Inspiration
We are two astronomers searching for potentially habitable planets beyond our solar system. Then one afternoon, walking across the University of Arizona campus, we heard a Cactus Wren calling from a palo verde tree slated for removal to build a parking lot on the National Championship Rd. The irony hit us: while we obsess over finding life on other worlds, rapid urban expansion is quietly dismantling the "habitable zones" of our wildlife neighbors right here in Tucson. We decided to apply the same data-driven rigor to our own backyard.
AskABird was born from one simple question: What would a Cactus Wren think if a new construction was built in its home? Before we find life in the stars, we should protect the life around us.
Why Birds?
Tucson sits at one of the most remarkable ecological crossroads on Earth. The Sky Islands funnel species from the Rockies, the Sierra Madre, and the Mexican tropics into a single region — southeastern Arizona regularly records 500+ bird species, roughly half of all North American species. More importantly, birds are the most commonly encountered wildlife for most people. They connect ordinary people to ecosystems they might otherwise ignore, and their populations are among the most sensitive, well-documented indicators of ecosystem health.
We are not anti-development. Cities grow and communities need housing, energy, and infrastructure. What AskABird argues is that where and how we build matters enormously. Getting a construction site right for birds means getting it right for pollinators, reptiles, and native plants too. Our goal is to surface the environmental question before the bulldozer arrives — not as a blocker, but as a nudge toward a slightly better coordinate.
Sustainable expansion isn't about stopping growth. It's about choosing the next 100 meters wisely.
How We Built It
| Layer | Technology |
|---|---|
| Frontend | React + Vite + TypeScript + Tailwind CSS + shadcn/ui |
| Map | Leaflet with custom biodiversity heatmap overlays |
| Backend | Supabase Edge Functions (Deno / TypeScript) — bird chat + professional report generation |
| Bird data | eBird API v2 (Cornell Lab of Ornithology) — real-time citizen-science sightings |
| AI | Gemma 4 (open-source) via Google Cloud Gemini API |
| Scaffolding | Lovable + Claude Code for rapid prototyping |
When a user drops a pin, the request flows through five Supabase Edge Functions: analyze-site fetches a 25 km eBird radius and runs our safety model; bird-chat streams a Gemma 4 response in first-person as the local bird; suggest-alternatives samples 40 candidate points on concentric rings (2–18 mi) and returns the three closest spots that pass the safety threshold; region-biodiversity powers the heatmap overlay showing endangered and migratory species; nearby-birds handles the species picker. The BirdChat component parses the SSE stream so the bird's words appear token-by-token, as if it's actually thinking.
The Math Behind It
The model computes a construction safety score \(S \in [0,1]\) from three criteria:
$$S_{\text{baseline}} = 0.5\,E + 0.3\,M + 0.2\,B + \epsilon$$
- \(E\) — Endangered safety (50%): drops with each ESA-listed or sensitive species found within 1 mile, saturating at zero for four or more.
$$E = \max!\left(0,\; 1 - \frac{|{s_i : d_i \le 1\,\text{mi}}|}{4}\right)$$
- \(M\) — Migratory pressure (30%): scores 1.0 if fewer than 10 migratory species are active within ~3.1 mi, decays to 0 at 25 species.
$$M = \begin{cases} 1 & \text{outside flyway or } N_{\text{mig}} < 10 \ \max!\left(0,\; 1 - \dfrac{N_{\text{mig}}-10}{15}\right) & \text{otherwise} \end{cases}$$
- \(B\) — Biodiversity sensitivity (20%): penalizes sites above the regional species average \(\mu\) within 25 km. Let \(e = n_{\text{site}} - \mu\) be the excess richness (zero if below average):
$$B = \max!\left(0,\; 1 - \frac{e}{\mu}\right), \qquad e = \max(0,\; n_{\text{site}} - \mu)$$
Each construction type then applies a signed per-criterion delta \(\delta_c\), weighted by habitat stress so harm bites harder in already-sensitive areas:
$$\Delta_{\text{adj}} = \delta_c \cdot \bigl(0.7 + 0.6\,(1 - s_0)\bigr), \qquad s_{\text{post}} = \operatorname{clip}(s_0 + \Delta_{\text{adj}},\;0,\;1)$$
A site is recommended when \(S_{\text{impact}} \ge 0.60\). That threshold is what the birds argue about.
Challenges We Faced
Latency vs. richness. eBird queries over a 25 km radius can take 1–3 seconds. We built a synthetic Sonoran Desert fallback so the app stays usable, clearly badged in the UI.
Streaming Gemma 4 through Supabase. Gemma 4 runs via the Google Cloud Gemini API. We wrote a thin conversion layer in the edge function to strip thinking tokens and re-emit only visible output in OpenAI delta format, leaving the frontend parser untouched.
Output Consistency with fine-tuned AI personas. We experimented with everything from few-shot examples to chain-of-thought to prompt templates, but the most effective lever was simply injecting more relevant data into the system prompt. For example, "You are a Cactus Wren who last saw a Gilded Flicker 0.8 miles south and an endangered Elf Owl 1.2 miles north..." This made the bird's responses feel grounded and specific, not generic. We also built a custom layer where the bird can directly reference the same data points shown in the UI, so follow-up questions like "How many endangered species are nearby?" or "What's the closest migration hotspot?" get accurate, data-backed answers instead of vague reassurances.
Turning numbers into empathy. A score of 0.5 means nothing to most people. We injected specific species names, statuses, distances in miles, and the nearest migration hotspot directly into the system prompt so the bird can answer follow-up questions with real data, not generic reassurances.
Avatars to increase reachability. We manually picked five bird ambassadors with gemini generated avatar photos to increase the reachability — Cactus Wren, Vermilion Flycatcher, Gambel's Quail, Greater Roadrunner, Great Horned Owl. This can be expanded easily in the future to apply to all other species so users can always talk to their favorite local birds.
What We Learned
- Ecological APIs are messy. Variable coordinate precision, provisional flags, and uneven coverage forced us to build a two-pass evaluation and lean on synthetic data for edge cases.
- AI personas need ground truth. Vague instructions produce generic platitudes. Specific species names and distances produce responses that feel genuine and are actually informative.
- Streaming changes behavior. Token-by-token output feels qualitatively different. People stayed in the chat longer and asked more follow-up questions.
What's Next
This scales anywhere. The scoring model is fully geography-agnostic — eBird covers 200+ countries and over a billion observations. Deploying AskABird for São Paulo, Nairobi, or rural Scotland requires only a regional synthetic-fallback config and local ambassador portraits. The weighted safety model, alternative-site search, and Gemma 4 bird persona run identically everywhere. A production rollout covering all of North America is one sprint away.
Better reports with more data. The current impact report is a prototype. With richer data, the same pipeline can support fine-tuned regression models trained on historical eBird time-series and documented construction-impact studies, species distribution models that predict where sensitive species are likely to be (not just where they were last seen), and native plants via iNaturalist, and automatic consultation flags based on detected species, turning a biodiversity score into an actual compliance checklist.
Near-term: integrate municipal zoning data for smarter alternative-site suggestions, community sighting reports to update scores in real time, and multi-language bird voices (Gemma 4 handles this natively) for Spanish-speaking communities across southern Arizona and northern Mexico.
Built With
- amazon-web-services
- chat-gpt
- claude-code
- gemini
- gemma
- gemma4
- godaddy
- google-cloud
- lovable
- react
- vite
Log in or sign up for Devpost to join the conversation.