When the network goes down in a disaster, the phones become the network. Every phone runs an AI agent that works for its owner, and the agents tell each other what they know, phone to phone. Each agent step is one typed call through Firebase AI Logic: Gemini when there is a connection, the on-device model when there is none. The phones link to each other over peer-to-peer Wi-Fi and Bluetooth; Firebase runs the agents, not the radio link.

Inspiration

A flood alert says water is coming. It does not say which shelter has what you need, which street is under water right now, or what your neighbors already know. That is when people need answers, and it is also when the network fails.

What it does

HighGround is an iPhone app. Its headline feature is an offline mesh of AI agents:

  • Phones link directly over peer-to-peer Wi-Fi and Bluetooth LE, with no internet and no cell signal. Measured with no connection at all: three agents in reach in about a second.
  • You tell your agent once ("I need to charge my phone, the power is out here"). No name, no address: the app does not ask for one and does not send one. Other agents see you only as an area about half a mile wide.
  • Your agent sends a typed need to every agent in reach; every phone relays it onward.
  • The other agents answer with what their own owners reported: a shelter with a charging station on a generator, a flooded street, a closed library. For a medical need one may ask a question back first; your agent answers from what you told it.
  • Your agent puts it together for you: where to go (a public shelter, never a person) and what to avoid, then draws the route on the flood map around the flood zones.
  • Firebase AI checks the route before you take it. The route is drawn by the phone; then the model (Gemini online, the on-device model offline) checks it against what the other phones reported, the FEMA flood zones, the NOAA forecast water and the saved map, and says go, take care or do not go, with the reason and the reports word for word. Measured offline with three agents: "Route checked: take care", 2.7 s on the device, quoting "Jefferson St is knee deep between 4th and 6th".
  • Your agent serves the others too. When another agent asks if a street is passable, yours answers from what you reported, without interrupting you.
  • Hybrid in every step. Each agent line is tagged with the model that produced it: "Gemini · Firebase AI Logic · 1.1 s" online, "On device · Firebase AI Logic · 1.8 s" offline. A phone with a connection saves the request to Firestore.
  • In the demo the three other agents run on a Mac over the same radio links, each answering from notes given to it.

The same assistant also answers questions about your own spot:

  • Ask (function calling). Gemini picks from 6 tools that run on the phone over data already saved there: FEMA flood zones, USGS lidar ground height, NOAA coastal inundation, NWS alerts, gauges, shelters and roads.
    • The screen shows each tool call live, e.g. water_height_at_me(all) → 4.5 ft, nearest_shelter → St. Peter & Paul, 0.46 mi, route → 0.88 mi by road around the flood zone.
  • Make my plan (structured output). A @Generable FloodPlan (decision, why, where to go, steps, what to bring), rendered as a checklist.
    • The same type is generated by Gemini online and by the on-device model offline.
    • A fixed safety rule can only make the decision more cautious, never less.
  • Check a photo (multimodal). The model reads the waterline against things of known size: Gemini online (16–24 in, reference "car door bottom"), and the on-device model with no signal (16 in on the same photo, 3.3 s).
    • The walk/drive verdict comes from the National Weather Service thresholds applied to that depth, not from the model.
  • Save any US area for offline. At a place outside the built-in counties, one button pulls FEMA's flood zones and a USGS ground-height grid for about 6.6 km around it onto the phone (228 zones, 3.0 MB, 6.5 s at Charleston City Market), shows the download in stages, and flies over what was saved. With no signal afterwards, Depth and Ask still answer there: zone AE, flood elevation 10 ft, ground 6.3 ft, 3.7 ft deep.
  • Hybrid. Offline (or with "On device" chosen), the same questions and the same plan run on the device through Firebase AI Logic, with the same tools and the county packs already on the phone.
    • With no model at all, the tools answer directly. The app never goes silent.
  • Map. FEMA zones and NOAA forecast water, plus an A* route on the phone that avoids flooded streets and hands off to Google Maps.

How we built it (Firebase)

  • Firebase AI Logic:
    • Gemini 3.5 Flash-Lite with function calling, guided generation (@Generable) and image input with a JSON schema
    • on-device inference through the same LanguageModelSession tool set
  • App Check (enforced) and Anonymous Auth: only the real app reaches Gemini.
  • Remote Config: model_cloud switches the model with no app update. A realtime listener applies it within seconds, and the badge shows the active model.
  • Firestore: saved places with offline persistence.
  • Hosting: the county data packs (v5) the tools read offline.
  • Stack: SwiftUI, MapLibre Native, PMTiles. Data comes from FEMA NFHL, NOAA (CO-OPS, coastal inundation, NWPS), NWS alerts, USGS 3DEP, OpenStreetMap and FEMA shelters.

Measured on an iPhone (Nov 27 and 29 2026)

Task Path Time
Ask Gemini 2.3–5.5 s
Ask on device 6.6 s
Plan Gemini 1.4–3.3 s
Photo check (103 KB upload) Gemini 2.7–4.4 s
Safe route A* on the phone 0.2 s
Route check (Nov 29) on device, offline 1.9–2.7 s
Photo check (Nov 29) on device, offline 3.3–3.5 s
Ask in a saved area (Nov 29) on device, offline 4.9 s
Save an area: 228 zones + ground grid (Nov 29) FEMA + USGS to the phone 6.5 s

Challenges

  • No made-up numbers. Every number comes from a tool, and the model only picks tools and phrases. Safety decisions have rule floors.
  • Privacy. The place you search for, its name and its coordinates never go to the log or to another phone; other agents see an area about half a mile wide.
  • Agreement. The plan, the route and the shelter answer must name the same shelter; we fixed a case where they disagreed.

What's next

An Android build of the app is in the repo, with the same mesh wire format. Measured on Nov 29 on a moto g 5G (2022, Android 13) next to the iPhone: the two apps linked over the same Wi-Fi in about 1 s and over Bluetooth alone in about 3 s (iPhone offline, Bluetooth on), and each phone's agent answered the other's question in under 2 s. On that Android phone the agent steps ran on Gemini through Firebase AI Logic; it has no on-device model, so with no connection the Android agent falls back to rules. The Android Bluetooth link reaches iPhones; two Android phones still need a shared Wi-Fi network. Next: Bluetooth between Android phones, an Android phone with Gemini Nano, more counties per pack, and live NWS river forecasts in the plan.

Built With

  • app-check
  • firebase-ai-logic
  • firebase-hosting
  • firestore
  • foundation-models
  • gemini
  • kotlin
  • maplibre
  • remote-config
  • swift
  • swiftui
Share this project:

Updates

Submission history