Inspiration

I've been riding an e-bike to closing shifts, ten miles each way, and home after dark. When something breaks at 11 PM, drivers have roadside assistance. People on bikes, e-bikes, skateboards and on foot mostly have a phone, and the phone often has no signal right where things go wrong. An AI that only lives in the cloud disappears at the exact moment you need it.

What it does

You say what happened, in your own words or with a photo. NIGHTRIDE Offline works out the problem and walks you through it one step at a time, out loud if you want. It keeps working with no signal.

Every request runs down four layers and stops at the first one that can answer honestly:

  1. Safety rules first. No model, no network. If someone is hurt, in danger, or a battery is smoking, the whole screen becomes one button: dial 911. Crisis words go to 988.
  2. Gemini Nano on the device. In desktop Chrome, through Firebase AI Logic. It reads messy words ("my chain fell off and now the pedals just spin") and photos, and picks the right repair card. Nothing leaves the laptop.
  3. Gemini in the cloud. The same Firebase AI Logic call, when there is no on-device model (most phones today) and there is signal.
  4. Field cards. Checked repair cards stored in the app, with every step recorded in a human voice. No model, no network. That is what a phone with no signal gets.

Also: open-late places from OpenStreetMap, saved for when the signal dies; a drafted text to someone you trust that you read and send yourself; and "Wrong problem? Pick another", so the rider always has the last word.

How we built it

  • One getGenerativeModel per task with mode: PREFER_ON_DEVICE, plus ONLY_ON_DEVICE and ONLY_IN_CLOUD switches so you can force either side and compare.
  • Structured output on both sides from one schema: responseSchema in inCloudParams, responseConstraint in onDeviceParams. The model must answer with a category and one card id from a fixed list, so it cannot invent repair steps when a checked card fits.
  • onDeviceParams.createOptions declares text and image input. initializeDeviceModel runs from a click so Chrome can load Nano with a user gesture.
  • response.inferenceSource drives the road across the top of the screen and a route log, so every answer shows where it ran and how long it took.
  • App Check with reCAPTCHA Enterprise on the live site, Firebase Hosting, and the Gemini Developer API on the free Spark plan. No billing.
  • Vanilla JavaScript and Vite, a service worker that keeps the app, the cards and the voice clips available offline, and 33 unit tests on the guard, the router and the sanitizer.

Challenges we ran into

In testing, Gemini Nano promised "I will dispatch an ambulance", invented a fuse box on an e-bike, and called a snapped chain an emergency. A safety app cannot ship that. So we stopped asking it to write advice. Nano does what it is good at, understanding messy words and photos, and chooses from cards a person checked. Hard rules, not a model, decide when to take over the screen, and the red 911 bar only shows when the rider's own words give a reason. A filter removes any promise of outside help.

Google Search grounding was not available on the no-cost plan, and plain Gemini will invent business hours, so places come from real map data instead.

Accomplishments that we're proud of

  • With the network off, the app reloads from its cache, Gemini Nano still answers, and the saved places and recorded voice are still there.
  • On the live site: a cloud answer in about 1 to 3 seconds; on device, about 20 to 27 seconds for the first answer of a session while Nano loads, then about 4 seconds.

What we learned

On-device models are great at understanding and poor at being trusted alone. The hybrid SDK made it easy to put Nano where it shines and keep the cloud as a fallback, and structured output on both sides made the two interchangeable.

Built during the submission period

The project existed before Nov 11 as a local prototype: never deployed, never published, no users. The repo tag pre-contest marks that state, and CONTEST_LOG.md lists everything after it. During the contest:

  • Deployed to Firebase Hosting with App Check moved to reCAPTCHA Enterprise; on-device and cloud answers verified on the live site.
  • Recorded voice for all 89 card lines, playable with no signal.
  • Fixed false 911 alarms: the red bar now needs a sign of danger in the rider's words.
  • Published the repo under Apache 2.0 and made the demo video.

Honest limits

It contacts nobody and is not an emergency service. On-device AI needs desktop Chrome today; phones get the cloud or the cards. Map hours can be out of date, and the app says so.

Disclosure

The narration and the card voice are the builder's own voice, generated from his own recording with a local voice model before shipping. The app plays audio files, and no voice model runs in the app. The riding scenes in the video are AI-generated illustrations made from his own reference photos. Music is his own (NoBanks Nearby). Built with Claude Code as a coding assistant.

What's next

On-device AI on phones as browsers add it (the same code already falls back), more languages, and cards written with bike mechanics.

Built With

Share this project:

Updates

Submission history