Inspiration
Walking home alone at night near campus is one of those risks every student just quietly manages — share your location in a group chat, text "landed safe," call a friend to stay on the line until you're inside. USC already has DPS escorts and blue-light phones, but there's no lightweight, social-first layer that fills the gap between "I'm fine" and "I need to call campus police." We wanted something closer to how people actually behave: a dot on a map that says someone else nearby is walking too, a one-tap way to ask a friend to walk with you, and a safety net that escalates on its own if you go quiet.
What it does
TrojanWalk is a phone-first safety-walk companion for USC students. Flip "Walking alone" on and you become one of several anonymous, rounded dots on a live campus map — you only see others while you're visible too, so nobody can silently watch without participating. From there:
- Walk with me — type a request in plain language ("leaving Leavey in 2, heading to the Lo") and an LLM parses the origin, destination, and leave time; it fans out first to friends and people who share your class or dorm, then to opted-in student Walkers nearby if no one answers.
- Broadcast — for when you need company right now and don't have a specific person in mind: an anonymous area alert goes out to everyone nearby and on-duty Walkers, surfaces the nearest staffed safe spots, and lets you approve one responder while the rest get a polite "someone else is on the way."
- Live session — once matched, both people see each other's dot, get periodic check-in prompts with a countdown, and the walk ends with a one-tap arrival confirmation and rating. Two missed check-ins escalates — SMS to the requester's emergency contact, then a DPS call prompt.
- Walker mode — students can opt in as verified volunteer escorts, set their availability hours and a gender-match preference, and get pinged (capped at a few requests a night) when no friend is available.
How we built it
Next.js 14 (App Router) and TypeScript on the frontend, styled from scratch with Tailwind and shadcn/ui rather than a generic dashboard look — dark background, a single red accent, phone-card layout instead of a desktop website. MapLibre GL with OpenFreeMap tiles renders the live map with zero API keys or billing required.
The backend is entirely Supabase: Postgres with PostGIS for geospatial queries, Realtime for session and request updates, Edge Functions (Deno) for the fan-out/respond/broadcast logic, and Row-Level Security locked down hard — coordinates never reach a client unless that client is an active session participant, enforced through a set of restricted, owner-privileged views rather than trusting the frontend to hide anything. pg_cron handles the background jobs: stale presence cleanup, request expiry, check-in sweeps, nightly ping-counter resets. Natural-language parsing runs through the Anthropic API with a strict JSON schema and a confidence threshold, falling back to a two-field form below 0.7 so a bad parse never blocks a request. Web Push (VAPID) delivers notifications with an in-app banner as a fallback when permission is denied, and Twilio handles the check-in-escalation texts (stubbed for demo).
We built almost the entire thing through conversational prompts to Claude Code — describing each screen and backend piece in plain language, reviewing what came back, and testing multi-user flows with Playwright running two isolated browser sessions side by side before moving to the next piece.
Challenges we ran into
We originally planned to generate the UI shell in v0.dev and wire it up in Claude Code afterward, but v0's export kept failing (a known sandbox bug, not a paywall issue) and the generated screens looked templated regardless — generic dark-SaaS defaults instead of something that felt like a phone app. We scrapped v0 entirely and rebuilt every screen directly, which actually produced a more consistent design system in the end.
The hardest part wasn't the UI, it was the privacy model: an early draft of the schema had functions that would have let any authenticated user query other students' raw coordinates, and a join bug in the matching logic that silently broke the "friends get priority" ranking. We rewrote the core matching function with explicit joins and deduplication, added grid-snapping so dots are only ever accurate to about 20 meters, and used security-definer functions plus owner-privileged views so the only way any location data reaches a client is through a narrow, audited path — never a raw table read.
We also hit the usual last-mile infrastructure friction: a Supabase service-role key that didn't match the project, an Anthropic key format we didn't recognize at first (personal-scoped keys use a different prefix than workspace keys), edge function secrets that need setting separately from the Next.js app's own environment variables, and a Vercel deploy that failed on a strict ESLint rule catching an unused variable that turned out to be a genuinely missing navigation call.
Accomplishments that we're proud of
Getting a real-time, privacy-preserving presence system working end to end — two independent browser sessions seeing each other's dot, heading calculated to within half a degree of the true bearing, and a dot that disappears the instant someone toggles off. The tiered matching logic (friends → shared context → opted-in Walkers) correctly excluded ineligible walkers in testing — wrong hours, gender mismatch, nightly cap reached — on the very first real run against the live database, not just in a code review. And the broadcast flow's access control held up exactly as designed: an unapproved responder genuinely cannot read the request's location, session, or any fix data, confirmed by actual 401/403-style rejections during testing, not assumptions.
What we learned
Postgres Row-Level Security is powerful but easy to get subtly wrong — the real protection often isn't the RLS policy on the table, it's a narrow, owner-privileged view that decides exactly which columns are ever allowed to leave the database, which is a different mental model than "just add a policy." We also learned that privacy-by-design sometimes means the honest answer to "why didn't I see anyone on the map" is "because you weren't visible either" — a deliberate trade-off, not a bug. On the infrastructure side: secrets live in more places than you expect (local env file, Supabase edge secrets, Vercel project settings), and a build that passes locally can still fail in CI over a lint rule that would never block a local dev server.
What's next for Trojan Walk
Finishing contacts-sync so friend connections come from a phone's contact list instead of being seeded manually, wiring up Web Push fully for walk requests and broadcasts, and field-testing with real GPS on a phone rather than simulated movement. Longer term: a trust and reporting system that actually suspends a Walker after repeated reports, a route-line overlay for responders heading to a broadcast, letting a requester choose among multiple staffed safe spots instead of always defaulting to the nearest, and exploring a pilot with USC DPS so escalations route into their existing dispatch workflow instead of a stubbed phone intent.
Built With
- deno
- gl
- gps
- javascript
- lucide-react
- maplibre
- next.js
- openfreemap
- pg-cron
- playwright
- postgis
- postgrest
- react
- realtime
- replit
- row-level
- shadcn/ui
- tailwind
- typescript
- vapid