Inspiration
About 46 large earthquakes happen every year, and thousands of smaller ones happen every day. Between 1998 and 2017, earthquakes killed nearly 750,000 people, more than half of all deaths from natural disasters in that period, and affected another 125 million through injuries and lost homes. Earthquakes also cut an area off from the rest of the world: roads crack, cell towers go down, and emergency services are overwhelmed within minutes, so survivors become the first responders.
Most earthquake deaths don't come from the ground moving. They come from buildings failing, and from people walking back into buildings that looked fine but weren't. The 2023 Turkey–Syria earthquakes killed more than 55,000 people, and roughly 84,000 buildings collapsed or were damaged beyond repair.
My area experiences over 1,500 micro-quakes every year, and I live close to the San Andreas Fault. Most homes have a smoke detector on every ceiling, but almost none have anything that can tell you whether your house just took structural damage. I kept coming back to one question: what would it take to give every household the kind of seismic monitoring that today only exists in skyscrapers, bridges, and government research networks? Seismic is my answer: one system that detects the earthquake, responds automatically, calls 911 if you can't, and tells you whether your building is safe to re-enter.
Why hybrid AI: While building Seismic's AI analyst, I ran into a contradiction that changed the whole architecture. The moment someone most needs an AI to explain whether their building is safe is right after an earthquake, and that is exactly when the cellular network is congested, damaged, or gone. A cloud-only assistant fails precisely when it matters most. A purely on-device model has a much smaller context window, so it writes weaker long-form explanations when the network is available. Neither extreme was acceptable for a life-safety product. Firebase AI Logic's hybrid inference resolved that tension: one SDK that runs a prompt on the device when a local model is available and routes it to Gemini in the cloud when it isn't, or when the task needs a larger model. That let me build an analyst that degrades gracefully instead of failing, across both iOS and the web, with one consistent design.
What it does
Seismic is a native iOS app and a Chrome web app, paired with a custom hardware sensor node. Together they form an earthquake detection, response, and structural-safety platform that combines sensing hardware, real-world data, physics-based 3D simulation, and a layered AI and machine-learning stack, including a hybrid on-device/cloud structural analyst built on Firebase AI Logic.
Side Note: The actual website has a different UI than the video as I updated the website after making the video. Everything else is the same
Seismic works as a closed loop: Sense → Decide → Act → Assess → Explain → Share. The hardware senses the shaking, an on-device detection pipeline decides whether it's a real earthquake or just a slammed door, the node acts by cutting utilities and starting the emergency countdown, the app assesses structural damage, the hybrid AI analyst explains that assessment in plain language (on the device or in the cloud, depending on connectivity and the task), and the network shares the event with every connected household nearby.
Hardware Node: An Arduino Mega 2560 is connected to an accelerometer, motion sensor, sound sensor, tilt switch, thermistor, photoresistor, and stepper motor. When an earthquake is detected, the stepper motor rotates to represent shutting off water and electricity (electrical systems become especially dangerous when water is present). The node never trusts a single sensor. A detection only counts when at least two of three independent channels agree (vibration, tilt, and sound), and that vote is then checked by a machine-learning classifier trained to tell real seismic waveforms apart from household noise like footsteps, slammed doors, washing machines, and dropped objects. In bench testing, this two-stage design cut false triggers from roughly 1 in 9 household disturbances to fewer than 1 in 140. After the utilities are cut, a photoresistor watches the power indicator to confirm the shutoff actually happened instead of assuming it did.
Automatic Emergency Response: When Seismic confirms a dangerous earthquake, it starts a countdown on the iPhone's Dynamic Island, the lock-screen Live Activity, and the hardware's display. If nobody cancels it, because the user is unresponsive or trapped, the app calls 911. The cancel window keeps false alarms off emergency lines, while a real emergency never depends on someone reaching their phone.
Hybrid AI Structural Analyst (Firebase AI Logic): After every assessment, the analyst turns the raw evidence (the building's natural period before and after the event, peak inter-storey drift, confidence, structural system, and computed damage probability) into a plain-language explanation of what changed, what it means, and what to do next. Every request is routed through Firebase AI Logic to one of two compute targets:
On-device: Apple Foundation Models on iPhone, and Gemini Nano through Chrome's built-in Prompt API on the web. It's free, private (the building's structural data never leaves the device), low-latency, and works with no network at all. In the cloud: Gemini through Firebase AI Logic (gemini-3.1-flash-lite on iOS, gemini-3.5-flash-lite on the web), protected by Firebase App Check, with no API key shipped in the app. It's used when the task benefits from a larger model or the device has no local model. Seismic routes each request using a policy based on task urgency, prompt size, and connectivity. Every answer carries a badge showing where it ran (On-device or Cloud), which model wrote it, and which inference mode was chosen, so the user always knows whether their data left the phone.
Ask About This Building: On iOS and the web, the Assess screen includes a question box for things like "Can I go back in to get my medication?" or "What would change this verdict?" Answers are grounded in that building's measured facts and constrained by its computed verdict. A "What do I do right now?" button produces a two-sentence, action-first instruction and reads it aloud with the device's own offline speech engine. Because these questions are short and urgent, they run on-device first, so they answer instantly even in airplane mode.
Hallucination-Proof by Design: A language model in Seismic can explain a verdict, but it can never change one. The verdict is computed deterministically from the evidence and passed to the model as a hard constraint. Every answer, from either the on-device or the cloud model, then passes a deterministic grounding check: if it contains any number that was never measured, it is discarded and replaced by a paragraph written from the measurements, and the screen states that the model's answer was rejected and why. A local model gets privacy and speed from this design, but not any more trust.
3D Simulation: The simulator shows how a building responds to earthquake forces, with movement exaggerated 40 times so damage is visible. Behind the visuals is a multi-degree-of-freedom shear-building model: every floor is a mass connected to the floor below by a spring and a damper, and the app solves the equations of motion step by step through a real recorded earthquake using Newmark-beta time integration. Peak interstory drift is mapped onto FEMA HAZUS-style fragility curves, which give the probability of slight, moderate, extensive, and complete damage. The app combines those into a damage percentage and a green, yellow, or red tag, the same language real post-earthquake inspectors use. Because a full physics solve takes a moment, Seismic also runs a neural surrogate model trained on 50,000 building-and-earthquake pairs generated by my own solver, which predicts the damage percentage in about 4 milliseconds. The user sees an instant estimate while the full physics runs in the background to confirm it, and the two agree within about 3% on buildings the model never saw during training.
Map: The Map uses Tavily, Serper, OpenWeather, and Wikidata to build an interactive map of earthquake statistics, historical activity, damaged buildings, and the probability of future activity. After an earthquake, Tavily and Serper pull live news and reports, a large language model running on Cerebras inference hardware extracts structured facts (building name, damage type, severity, and location), Wikidata and OpenStreetMap match each report to a real building footprint, and duplicate reports are merged so one collapse doesn't become five pins. Every pin carries a confidence score and a source link. Future-activity probability combines USGS aftershock forecasts with a Gutenberg-Richter model fitted to the local catalog by maximum-likelihood estimation, converted into the probability of at least one quake above a chosen magnitude over the next day, week, or year.
Home: Customizable, live-updating widgets summarize the building's health, the latest nearby quakes, the hardware's status, and the network around you.
Network: Multiple nodes communicate across a city, state, or country. When one node detects an earthquake, it notifies connected households in the affected area. Each alert carries a precise timestamp and the classifier's confidence, so when several homes trigger at once, Seismic uses arrival-time differences to estimate where the earthquake started (the network-inversion idea professional seismic networks use) and uses agreement between nodes to confirm that an event is regional rather than one noisy sensor.
Feed: A continuously updating tracker of earthquakes worldwide, with each event enriched by its distance from the user and whether any connected node felt it.
Library: Importing a real-world building launches an AI research agent: the language model plans searches, reads the results, extracts height, floors, year built, structural system, and material into a strict schema, and cross-checks every value across multiple sources. When a value can't be found (almost no building publishes its weight), a regression model estimates it from floor area, floor count, and material, and labels it as estimated. Tested against 60 buildings I checked by hand, the agent filled 92% of fields correctly.
Web App (Chrome): Seismic also runs as a full web app in Chrome, hosted on Vercel, with the same sixteen sections, orb navigation, and hardware path as the iPhone app. The node connects over Web Bluetooth or USB (Web Serial). The web build includes the full hybrid analyst: Gemini Nano runs inside Chrome for on-device answers, and Firebase AI Logic routes to Gemini in the cloud when needed. A Settings panel shows whether the browser has an on-device model and downloads Gemini Nano with one click.
Settings: Settings customizes background, haptics, and voice, and explains every calculation, algorithm, and AI model, including which inference providers are available, whether the on-device model is ready, and which cloud model is configured. Every number can be traced to the algorithm that produced it, and every AI answer shows where it was computed.
Authentication: Apple Login, Google Login, and username-and-password, with data synced securely to the cloud.
How Seismic compares: Existing tools each solve one slice of the problem.
MyShake and ShakeAlert give a few seconds of warning, but only cover California, Oregon, and Washington, only alert for roughly magnitude 4.5 and up, and stop at the warning. They don't shut anything off, call for help, or assess your building. Android Earthquake Alerts turn phones into crowdsourced seismometers, but phones in pockets and on tables are noisy sensors. During the 2023 Turkey earthquake, Google later said the system estimated the magnitude 7.8 quake at only about 4.5 to 4.9 and sent its highest-level alert to just 469 people, even though about 10 million lived within 158 km of the epicenter. Seismic's node is fixed to the structure, with three independent channels, voting, and a trained classifier. Seismic gas shutoff valves are purely mechanical: a ball drops at a threshold, protecting one utility, with no notification or data. Seismic controls water and electricity, verifies the shutoff, logs it, and tells your phone. ATC-20 inspections are the gold standard, but after a large quake there can be tens of thousands of buildings and few inspectors, so families wait days. Seismic gives a preliminary, data-backed green/yellow/red assessment within minutes and can help prioritize inspections. It supports inspectors; it doesn't replace them. Cloud-only AI chatbots need a network, send your data to a server, and can invent numbers. Seismic's analyst runs on-device when the network is down, keeps structural data local when it can, and is mechanically prevented from presenting a figure that was never measured. Commercial structural health monitoring uses the same family of algorithms but has historically cost more than $5,000 per sensing channel; one bridge system cost about $1.3 million for 86 accelerometers. The Seismic node uses about $85 of parts.
How we built it
Architecture: I built the iOS app in Swift, SwiftUI, and Swift Package Manager, organized into seven modules: SeismicCore, SeismicSignal, SeismicGeo, SeismicStructures, SeismicDevice, SeismicData, and SeismicServices. The modules have a strict one-way dependency graph (SeismicCore depends on nothing, and the UI depends on everything), so every algorithm can be validated in isolation without launching the simulator, and any model can be swapped or retrained without touching the rest of the app.
Signal processing: The pipeline implements waveform conditioning, STA/LTA event detection, matched filtering, Welch power spectral density, spectral peak picking, Hilbert envelope analysis, damping estimation, and response spectra. Raw accelerometer data is detrended and band-pass filtered to remove drift and electrical hum. The STA/LTA detector compares a 1-second short-term energy window against a 20-second long-term window and fires when their ratio crosses an adaptive threshold that rises in noisy environments. Damping is estimated two independent ways: half-power bandwidth of the spectral peak and logarithmic decay of the Hilbert envelope. The response spectrum runs hundreds of single-degree-of-freedom oscillators at 5% damping across periods from 0.05 to 10 seconds. Three natural-period methods (Welch peak picking, autocorrelation of the free-vibration response, and the ASCE 7 empirical height formula) are compared side by side, and every step is plotted.
Machine-learning layer: The first model is the on-device earthquake classifier. For every triggered window, Seismic extracts a 38-feature vector (Welch band energies, dominant frequency, STA/LTA ratio, envelope rise time, kurtosis, zero-crossing rate, tilt change, sound energy, and motion-sensor occupancy) and feeds it into a gradient-boosted decision-tree model exported to Core ML. The model is about 40 KB and runs in under a millisecond on the iPhone. I trained it on roughly 22,000 labeled two-second windows: real earthquake waveforms from the Stanford Earthquake Dataset (STEAD), resampled and rescaled to match my MPU6050 accelerometer, plus more than 4,000 household-noise recordings I captured myself, augmented with injected noise, amplitude scaling, and time shifts. The second model is the neural damage surrogate, a three-layer network that takes building properties (height, floors, mass, material, damping, natural period) and ground-motion intensity measures (PGA, PGV, and spectral acceleration at the fundamental period) and predicts damage percentage. Because it is trained entirely on data from my own physics solver, it inherits the physics but runs about 400 times faster. The third is the Library's regression model for missing properties like total mass.
Hybrid Generative AI Layer (Firebase AI Logic): On top of the ML layer sits a generative layer I rebuilt around Firebase AI Logic so the analyst could run on two compute targets across two platforms. It has five parts.
A provider-agnostic inference abstraction. In the core Swift package, a HybridInferenceBackend protocol returns a structured HybridCompletion: the text, an inference source (on-device or in-cloud), and the model identifier. The analyst actor tries the Firebase hybrid backend first, and every result flows through the same caching, grounding, and provenance-reporting pipeline. The core package does not depend on Firebase at all; the Firebase implementation is injected from the app target, so the 981-test suite still runs with swift test on any machine with no network.
iOS: Foundation Models and Firebase AI Logic behind one session API. On-device, the app uses Apple's SystemLanguageModel through a LanguageModelSession. For the cloud on iOS 27, I use Firebase's GeminiLanguageModel, which conforms to Apple's LanguageModel protocol, so Gemini runs inside the same LanguageModelSession API as the on-device model. The two targets differ only in the model object handed to the session: same instructions, same calling convention, same response type. On earlier iOS versions, the cloud side falls back to Firebase's GenerativeModel generateContent call. Availability is checked live through Apple's model availability API, which distinguishes an ineligible device, Apple Intelligence switched off, and the model still downloading, each with its own user-facing explanation.
Web: SDK-native hybrid inference. In Chrome, I use Firebase AI Logic's hybrid mode through getGenerativeModel with a mode, in-cloud parameters, and on-device parameters. The in-cloud parameters carry the Gemini model, system instruction, and output-token ceiling. The on-device parameters configure Chrome's Prompt API session (expected input/output modalities and languages, plus the same system prompt as an initial system turn), so both targets receive identical instructions. After each call, I read the response's inferenceSource to record where the request actually ran, rather than assuming the requested mode was honoured. Gemini Nano's multi-gigabyte download starts through initializeDeviceModel from an explicit user gesture, with live progress reporting.
A cost- and context-aware routing policy. Each request is routed on three signals: task urgency, prompt size relative to the on-device context window, and connectivity. Spoken guidance (45-word budget) and typed questions (90-word budget) are short and latency-critical, so they run device-first (PREFER_ON_DEVICE). The full written assessment (180-word budget) benefits from a larger model, so it runs cloud-first (PREFER_IN_CLOUD), falling back to the device. Prompts that would overflow the on-device window skip the device (ONLY_IN_CLOUD). Apple's on-device model shares a 4,096-token window across instructions, prompt, and answer, so the iOS router estimates token usage from character counts (about 4 characters per token) plus expected answer length, and routes oversized prompts to Gemini. When the browser reports it's offline, the web build switches to ONLY_ON_DEVICE. On iOS, a failed cloud call falls through to Apple's model automatically. Output-token ceilings are derived from each task's word budget, and on-device generation runs at a low temperature (0.3), because the model is restating measurements, not writing creatively.
Grounded prompting and deterministic verification. Every prompt is assembled from structured facts, each labelled with its value and provenance (measured, library, or estimated), plus explicit constraints such as the verdict, the computed damage probability, and "this is a screening measurement, not an inspection." The system prompt sets rules in priority order: never introduce a number, date, material, or building name not in the facts; never contradict a constraint; never declare a building safe to occupy; say plainly when evidence is thin. After generation, a deterministic grounding verifier tokenises every numeric value in the answer and checks it against the numbers in the facts, constraints, and subject. It allows only a small set of ordinary prose numbers, and accepts rounded restatements through prefix matching (so "1.04 s" passes for a measured "1.043 s"). Any answer that fails is discarded, and a deterministic narrator writes a replacement from the same facts. I ported this layer line for line from Swift to JavaScript so both platforms enforce the same contract.
Security with Firebase App Check: Firebase AI Logic requires App Check, which attests that requests come from the genuine app before any Gemini quota is spent, so no Gemini API key exists anywhere in the client code. On iOS, App Check is initialised with the debug provider before Firebase is configured. On the web, it's initialised before the AI client, supporting either a registered debug token or a reCAPTCHA Enterprise site key for production. I bundled Firebase JS SDK 13.4.0 into the repository and rewrote its internal module imports to relative paths, which let the web app keep a strict self-only Content Security Policy that allows only the Firebase AI Logic and App Check endpoints, and means the AI client loads even when the network doesn't.
Structural health monitoring: When a building is damaged it loses stiffness, so its natural period gets longer; tracking that period is one of the strongest damage indicators in structural engineering. Temperature does the same thing, shifting frequency by a few percent between a cold morning and a hot afternoon. To separate the two, a building-specific temperature-frequency regression model is learned using the node's thermistor and outdoor temperature from OpenWeather, with robust regression and outlier detection on the same data. An evidence-based reasoning engine works like a Bayesian evidence-fusion system: it starts from a prior damage probability from the simulator's fragility curves and updates it with each independent line of evidence (period shift, residual displacement, and tilt), with weights and plain-language annotations at every step. It produces an assessment with a bootstrap confidence interval. That assessment, its evidence, and its confidence are exactly what the hybrid analyst receives as grounded facts, so the generative layer explains the reasoning engine's output and never replaces it. A Coordinate Modal Assurance Criterion (COMAC) analysis compares mode shapes before and after an event to help pinpoint where a change occurred.
3D simulator: The simulator uses the building description and historical seismic traces to visualize ground shaking, with vibration modes, response spectra marked with the building's natural period, frequency comparisons, an animated spectrogram, and sonification. Buildings sway at roughly 0.1 to 10 Hz, far below human hearing, so shifting every frequency up six octaves (multiplying by 64) makes them audible: a building swaying at 1.2 Hz becomes a 77 Hz hum, and you can hear the pitch drop when a damaged building loses stiffness.
Sensor node and protocol: The Arduino Mega 2560 node monitors shaking, tilt, sound, temperature, and occupancy, runs the two-out-of-three voting scheme, and drives real-time telemetry, countdown display, audible alerts, transistor-controlled relays, and a stepper motor for the water shutoff. It samples the MPU6050 at 200 Hz into a circular buffer, so a recording includes the seconds right before the trigger. The protocol uses newline-delimited JSON, and every message carries a checksum and sequence number. Because BLE packets carry only about 20 bytes of usable data by default, recordings are split into numbered chunks, and the app requests selective retransmission of only the chunks that arrived corrupted or missing. The web build speaks the same protocol through the same parser over Web Bluetooth and Web Serial, so one node can drive either platform.
Geospatial module: Seismic uses USGS earthquake data and aftershock forecasts, OpenStreetMap, and Wikidata. The network-inversion tools solve for the epicenter and origin time that best explain the arrival times at each node using an iterative least-squares solver; in tests on simulated six-node networks, the median epicenter error was 2.7 km. Distances use the haversine formula on the curved Earth, and nodes are grouped with geohashes so alerts reach only households inside the affected zone. Built-in historical, building, and synthetic sensor data let the app demonstrate everything on first launch.
Data, trust, and safety: The measurement log is tamper-evident: every entry contains a SHA-256 hash of the entry before it, so editing any past reading breaks every hash after it. The AI analysis module runs through a provider chain led by Firebase AI Logic hybrid inference (Apple Foundation Models or Gemini Nano on the device, Gemini in the cloud), with a Cerebras-served language model available as an additional keyed provider, and its output must match a strict JSON schema that the app validates before showing anything. I followed one rule throughout: AI where it helps, determinism where lives depend on it. The language model is never part of the alert path. Every safety-critical alert, countdown, and spoken warning comes from deterministic, fully tested code and on-device speech, so the system can't hallucinate during an emergency and keeps working with no internet.
Testing: I wrote 981 Swift tests across the seven modules and 61 JavaScript tests for the web build, more than 1,000 in total. The AI tests use a fake hybrid backend to verify that an on-device answer is accepted and labelled as on-device, that a cloud answer is marked as live, that an answer containing an invented figure is rejected and substituted, and that a failing hybrid backend falls through cleanly to the next provider. The web tests cover the routing policy (offline forces device-only, urgent tasks prefer the device, long write-ups prefer the cloud, oversized prompts skip the device) and the grounding verifier. Many numerical tests are golden tests that compare my Swift implementations against reference outputs from SciPy and NumPy to within one part in a billion, and the communication protocol is fuzz-tested with deliberately corrupted packets.
I used Claude for debugging, for code involving complex differential equations and matrix calculations, and to help integrate the Firebase AI Logic SDK. Apart from that, most of the work was my own.
Challenges we ran into
BLE Connection: Data arriving on the phone was riddled with errors. I reworked the hardware repeatedly before realizing BLE was cutting off part of each message, because BLE only carries about 20 bytes of usable data per packet by default and my sensor readings were far larger. I built a system that splits every message into small numbered chunks, each with a sequence number and checksum, so the phone can detect exactly which pieces were lost or corrupted and request only those. Packet loss dropped from about 14% to under 0.1%.
Lag on Phone: The fast stream of chunks made the app lag, and within 30 seconds my phone would crash. Most of the lag came from rendering the graph and formatting text on every packet. I built a ring buffer where the iPhone stores raw numbers off the main thread, then pulls data at a steady pace, compresses it into chunks, and only then updates the graph and statistics. Graphs are downsampled to only the points that change the line's shape. The app went from crashing after 30 seconds to streaming for more than four hours at a smooth 60 frames per second, with CPU usage dropping from nearly 100% to around 11%.
Simulation Rendering: Early simulations didn't match a reference project because of a rendering error that skewed the motion. I built a hidden simulation that used spatial linear averages and regression to find each floor's center of mass and center of stiffness, then combined their 3D coordinates with the force vectors and the equations of motion. The simulator then matched the reference within 2%.
Training Data for Earthquakes That Don't Happen on Command: My first classifier, trained only on my own recordings, flagged almost everything as an earthquake, including my little brother jumping down the stairs. I combined thousands of real waveforms from a public research dataset, resampled and rescaled to match what my accelerometer would actually see, with more than 4,000 household-noise recordings, and augmented everything with noise, scaling, and time shifts. The hardest part wasn't the model; it was making the data honest.
Keeping the AI From Making Things Up: The first Library research agent would invent a building's height or floor count when it couldn't find the answer. In a safety app, a made-up number is worse than no number. I forced a strict schema, required a source for every value, cross-checked values across results, and rejected anything that didn't agree. Unverifiable values are labelled as estimated.
The SDK Moved Faster Than the Documentation: The published Firebase guides for iOS hybrid inference described a HybridModel type and a GenerativeModelSession, but in Firebase iOS SDK 13 neither existed. Version 13.0 replaced them with GeminiLanguageModel, which plugs directly into Apple's Foundation Models LanguageModelSession. I read the SDK's source, changelog, and integration tests to find the real API surface and its availability annotations (iOS 27 for the Foundation Models integration), then designed the router so both paths share Apple's session API on iOS 27, with a separate cloud path for earlier versions. On the web, the documentation says inferenceSource returns ON_DEVICE or IN_CLOUD, but the shipped SDK returns lowercase on_device and in_cloud; the first successful Gemini answer crashed the Assess screen. I normalised the value and made the panel fail in isolation, so an AI rendering error can never take down the safety verdict next to it.
Fitting a Safety Explanation Into a Tiny Context Window: Apple's on-device model shares a 4,096-token window between instructions, prompt, and answer, and a full assessment can approach that limit. Rather than truncating facts (which could drop the evidence that matters most), I built size-aware routing that estimates each prompt's token footprint plus expected answer length and sends anything that won't fit to Gemini in the cloud.
Making Two Different Models Obey the Same Rules: A small on-device model is more likely to drift and embellish than a large cloud model, and I didn't want on-device answers held to a lower standard. Both receive identical instructions (the cloud model as a system instruction, the on-device model as an initial system turn), and both go through the same grounding verifier, implemented identically in Swift and JavaScript. Getting the rounding rules right, so "1.04 s" passes for a measured "1.043 s" but an invented "3.7%" drift never does, took several iterations and its own tests on both platforms.
App Check and the On-Device Model on Real Devices: Firebase AI Logic refuses any request without a valid App Check token, so a new device or browser silently fails until it's attested. I wired App Check into both platforms before the AI client initialises, set up debug tokens for development and judging, and made every failure degrade gracefully (cloud, then on-device, then deterministic narrator) with an on-screen note. On the web, Gemini Nano must be explicitly downloaded, and Chrome only allows that from a user gesture, so I built a Settings panel that detects the model's state (available, downloadable, downloading, or unavailable) and starts the download with progress reporting.
Interfaces That Fight Their Own Animations: The full-screen earthquake warning re-renders every 50 ms to keep its countdown live, so the "End drill" and "I'M SAFE" buttons were destroyed and recreated between press and release, and the browser never registered a click. Separately, the orb navigation captured the pointer for its sweep gesture, redirecting every tap to the background. I fixed the first by handling button actions on the container that survives each re-render, and the second by resolving the element actually under the pointer on release, and verified both with real input events through the Chrome DevTools Protocol.
Accomplishments that we're proud of
I turned Seismic from a concept into one platform that combines native iOS and web development, embedded electronics, structural engineering, scientific computing, geospatial analysis, machine learning, and hybrid on-device/cloud generative AI. It does what usually takes several separate tools, or isn't available to regular households at all.
I'm especially proud of the hybrid AI architecture, because it turns a hardware limitation into a safety feature. The same question can be answered by Apple Foundation Models on an iPhone in airplane mode, by Gemini Nano inside Chrome, or by Gemini in the cloud through Firebase AI Logic, and the user always sees which one answered. The routing policy matches each request to the right compute target, the verification layer holds every model to the same standard, and the design runs identically on two platforms. Building one AI contract across Swift and JavaScript, with Foundation Models, Chrome's Prompt API, and Gemini behind it, was one of the hardest and most satisfying parts of the project.
I implemented 74 algorithms for signal processing, structural engineering, statistics, geospatial computing, and mathematical modeling, with interactive visualizations that expose the waveforms, spectra, peaks, and calculations behind every number instead of an unexplained result.
The machine-learning layer works with the physics instead of replacing it. The classifier turned a $3 accelerometer into a detector that can tell an earthquake from a slammed door, cutting false triggers by more than 15 times. The damage surrogate learned from 50,000 simulations from my own physics engine, so it answers in milliseconds while staying grounded in structural mechanics. Every AI feature is checked: the surrogate by the full solver, the research agent by multiple sources, every analyst answer by the measured facts, and the language model is kept completely out of the emergency path.
On the hardware side, closing the loop with photoresistor feedback, so the system verifies that a utility shutoff actually happened instead of assuming it, is the contribution I'm most proud of. The whole node is built from about $85 of parts.
Finally, more than 1,000 automated tests (981 Swift and 61 JavaScript), including golden tests against SciPy and NumPy and fuzz tests of the protocol, make every algorithm and the hybrid AI layer verifiable.
What we learned
On the machine-learning side, I learned that a model is only as good as its data: most of the real work went into collecting, cleaning, labeling, and augmenting data, not training. Using my own simulator to generate training data showed me how powerful combining physics with machine learning can be. I also learned to design around AI's weaknesses by validating every output, requiring sources, and never letting a language model make a safety-critical decision.
Hybrid AI taught me that where a model runs is as much a design decision as which model runs. On-device inference isn't just a cost saving: in a disaster it's the difference between an answer and no answer, and it keeps sensitive data about someone's home on their own device. Cloud inference is the right tool when the context is too large for a small model or the explanation needs more depth. I learned to treat the two as complementary targets with explicit routing rules, to measure where each request actually ran, and to hold every model to the same verification standard. I also learned how App Check changes the security model of a client-side AI app (no API keys in the code, only attested apps can spend quota), and that when an SDK is evolving quickly, its source code and tests are the real documentation.
I also learned native iOS development, Google Sign-In, syncing live data to Supabase, complex Arduino circuits, and reliable BLE communication, plus a lot about the physics of earthquakes and how buildings respond to them. Most of all, I learned the importance of honesty in engineering: it's easy to make an app that sounds confident, and much harder, and more important, to make one that tells you how confident it really is and where its answers came from.
What's next for Seismic
Worldwide Accessibility: Many of the most earthquake-prone regions, like Turkey, Nepal, Indonesia, and Latin America, are where an affordable system could save the most lives, but the app is English-only. The on-device and cloud models can be configured with expected input and output languages, so the analyst could explain a verdict in the user's own language, still offline.
Deeper Firebase Integration: With Firebase Remote Config, routing thresholds, inference modes, cloud model choice, and per-task word budgets could be tuned without a new build, and staged rollouts could compare routing policies on real devices. Firestore could sync each building's assessment history and analyst explanations across a household's devices, and Firebase Authentication could unify sign-in across iOS and the web. For production, App Check would move from debug tokens to App Attest on iOS and reCAPTCHA Enterprise on the web. I'd also like to use on-device structured output and function calling, so the analyst returns typed, schema-validated recommendations instead of free text.
Expanding Hybrid AI to Vision: Photo-based damage analysis currently relies on a cloud model. As on-device multimodal models mature, the same routing could let a user photograph a crack and get an on-device first-pass description, escalating to the cloud only when a larger model is needed and a network is available.
Hardware Enclosure and Power: The node is currently a jumble of wires tethered to my laptop. A 3D-printed enclosure would organize the sensors, make connections readable, and mount rigidly to the structure for better accelerometer coupling. It also needs a rechargeable battery with low-battery alerts, because power is often the first thing to fail in a disaster.
Longer-Range Connectivity: The BLE link drops when the phone is off or out of range. Wi-Fi or LoRa would extend it across a house or neighborhood, and the node should be able to shut off utilities entirely on its own, even if the phone is never reachable.
UI Cleanup: Some users may find the interface overwhelming, so I want to simplify it for readability.
Real-World Validation: Every model has been tested on simulations, public datasets, and bench tests. The next step is a real shake table with scale-model buildings, and eventually a university earthquake engineering lab, to measure accuracy against ground truth and keep improving the classifier, the damage surrogate, and the analyst.