Inspiration

A night out can change in a few minutes. Friends split up, someone stops answering, or the ride home falls through. You check the group chat, call a friend, and look at the map. Even if you find their last location, you still have to figure out who’s going to check on them.

We built SafeNight around that moment. Friends can choose what they share before heading out, ask for help when they need it, and see who’s agreed to show up.

What it does

SafeNight helps friends stay in touch during a night out and coordinate if someone needs help getting back to the group or getting home.

A group for the night. A Night Out is a temporary group that expires. Friends accept their own roles, including designated driver and safety buddy. Each person chooses who can see their approximate or precise location, receive check-ins, or message them. They can revoke those permissions at any time.

Quick check-ins and help requests. Tap I’m okay to update the group or Need help to open an incident. SafeNight shows when a message was sent, when it was delivered, and when someone actually agreed to help. A routine check-in leaves an open incident in place until a person confirms the outcome.

Follow-up when a friend doesn’t answer. NVIDIA Nemotron proposes whom to contact first, when to follow up, and whether to reach out to a backup buddy or offer a ride. The backend checks every proposed action against consent and the current incident state before it runs. Each step leaves a receipt showing whether it came from the model, a policy rule, or a simulation.

Walking directions to a friend. Tap Come to me to ask someone to meet you. The friend who accepts gets a live map with both positions, GPS accuracy circles, an estimated distance, and walking directions in Apple Maps or Google Maps. SafeNight shares precise location between those two people for the meetup and revokes those temporary permissions when they confirm arrival.

A ride home and a final check-in. SafeNight can offer ride provider links so a person can book directly. The rider or their buddy can confirm pickup. The person the incident is about confirms when they’re home, which closes the incident and updates the group’s timeline.

Privacy controls throughout. The server limits what each person can see based on the permissions their friends granted. Location sharing expires, and Delete my data lets users remove the personal data SafeNight holds about them.

How we built it

SpacetimeDB is the backend. One TypeScript module on Maincloud holds sessions, members, consent grants, incidents, meetups, timers and agent state as tables and reducers: 40+ tables and 50+ reducers, each write a transaction with auth and rate limits. Per-user views are consent-scoped. Scheduled reducers run check-in timers, follow-up escalation and sweeps. The do-not-drive warning is an event table with row-level security, so only the driver's connection receives it. The Come to me stream is a private table updated in place up to four times a second and pushed to the one partner allowed to see it. A small Node bridge handles voice and messaging through ElevenLabs and Photon.

The agent lives inside the database. A scheduled procedure calls nvidia/nemotron-3.5-super through NVIDIA NIM with a strict tool allowlist. Tool results are fed back for up to three rounds, every call is validated against consent and incident state before it executes, and message templates are filled server-side so the model never writes free text to a friend. If the model is unreachable, a deterministic planner takes over and the receipt says so.

The client is a React + Vite progressive web app on Vercel, added to the home screen from Safari, so there is nothing to install. One WebSocket to SpacetimeDB carries reducers up and subscriptions down. Leaflet and OpenStreetMap for maps, Geolocation and device sensors for position, OSRM foot routing and a maps hand-off for directions.

119 module tests run the real database in-process, covering consent revocation, unauthorized access, duplicate events, escalation, prompt injection and the trip lifecycle. 149 web tests cover the live adapters, geometry, routing and accessibility, plus repeated end-to-end runs with four identities on real phones.

Challenges we ran into

A compass is the wrong instrument for GPS. Our first Come to me was an arrow: bearing to your friend minus the phone's heading. On real phones a few metres apart, with 5 to 40 m of GPS error, the arrow spun. We pulled the raw fixes from the server, confirmed the separation was smaller than the error, researched the alternatives (Bluetooth ranging isn't available to web apps on iOS; Ultra-wideband needs a native build) and rebuilt the feature as a live finder map with accuracy circles, uncertainty on the distance, and walking directions. The honest interface beat the impressive one.

Letting the model plan without letting it act. Nemotron sometimes wanted to hand off to dispatch or message the person in trouble. The fix was structural, not prompt-based: an allowlist, a validator, server-filled templates, a hard rule that only humans resolve, and receipts that name the source of every step.

Consent that holds under pressure. Trip-scoped precise sharing had to override a person's "approximate" default for exactly one other person, and had to end on arrival, on cancel, or whenever the incident closes by any path. We wrote tests for each of those exits.

Real time on real phones. Service workers that cached the old shell forever, iOS permission prompts that only fire from a tap, rate limits that had to make room for a high-rate stream without opening a flood. Each one was a small lesson in where the browser ends and the device begins.

Accomplishments that we're proud of

A multi-phone safety flow where every state is distinct and visible, running on one database with no middle tier. An agentic workflow where the model proposes, policy decides, and a person always closes the loop. Privacy as a property of the data layer, enforced by row-level security rather than by UI code.

What we learned

SpacetimeDB collapsed what would have been a server, a queue and a push service into reducers and subscriptions; the warning reaches the driver's phone in under a second with nothing in between. Agentic AI is safest when its output is a plan over a small set of tools and the policy layer owns the decisions. And measuring beats guessing: one look at the raw GPS data told us more about the compass than an evening of tuning.

What's next for SafeNight

A native iOS build with the lock-screen Live Activity we prototyped and Ultra-wideband direction between phones. Real messaging and voice through the bridge once carrier approval lands (Nemotron and SpacetimeDB are live today; messaging is simulated and labeled). Venue partnerships for the reports layer.

Built With

  • claude
  • codex
  • nemotron
  • photon
  • spacetimedb
  • websocket
Share this project:

Updates

Submission history