An ephemeral, privacy-first real-time group location & outing companion PWA — spin up a temporary group with a QR code, walk a shared multi-stop route, get smart anti-spam separation alerts, and watch all raw location data vanish automatically after 24 hours.
Try Live Demo · Product Vision · Features · Engineering & Algorithms · Privacy & RLS · Quickstart & Deploy
Walking streets, music festivals, and night markets are electric — until someone lags behind at a street-food stall and disappears into the crowd.
| Approach | What goes wrong |
|---|---|
| Group chat apps | "Where are you?" gets buried in noisy threads; static pins go stale the moment anyone walks 20 meters. |
| Always-on family trackers | Too invasive for a single evening with friends — nobody wants permanent 24/7 surveillance just to hang out. |
| 📍 Tagalong | Ephemeral, session-scoped location sharing: join in 5 seconds with a 6-digit code or QR, stay together on one live dark map, and have every raw GPS coordinate & chat message purged automatically 24 hours after the outing ends. |
Open tagalong-one.vercel.app and tap "Xem demo" — no sign-up, GPS permission, or backend required.
Demo group 482915 simulates 9 friends walking a 4-stop itinerary around Nguyễn Huệ Walking Street, Saigon, showcasing real-world edge cases live on the map:
- 🚶 Separated member — drifts past the group's median radius and triggers a separation alert
- 📶 Lost signal (
stale) — no GPS heartbeat for > 60 seconds, clearly distinguished from live pins - 🚪 Left app (
left_app) — tab backgrounded/closed without causing false separation spam - 🔋 Low battery — live battery status badge surfaced to the rest of the group
Running locally without
.env? Open two browser tabs in the same group — Tagalong automatically syncs state across tabs in demo mode.
- Instant lobby & join: Create an outing with configurable auto-end duration (≤ 12 hours) and separation radius (50 m / 100 m / 200 m).
- Zero-friction onboarding: Share a 6-digit code, QR code (
qrcode.react), or direct invite link/s/<code>. Friends join with just a display name via Supabase Anonymous Auth (or optional Google Sign-In). - Hard group cap: Supports up to 20 members per session, enforced right inside PostgreSQL Row Level Security.
- Dark-mode native map: Powered by MapLibre GL + CARTO Dark Matter vector/raster tiles with the custom "Tagalong Dark Pulse" visual language.
- Honest presence states: Clearly differentiates
live,stale("Mất sóng" after 60 s),left_app, andhidden(user paused sharing) alongside live Battery Status. - Pocket Mode (Battery Saver): Uses the Screen Wake Lock API behind an OLED-friendly pure-black lock screen so GPS tracking stays alive in your pocket. Double-tap to wake.
- Computes the group's true center via the geometric median of live members — a single straggler can never skew the center.
- Fires only when someone remains beyond the threshold for 30 continuous seconds (filtering out urban GPS jitter).
- Built-in 5-minute cooldown per member (re-escalating immediately only if they drift +100 m further).
- Combines an in-app alert banner, Browser Notification, and a "Call Back" nudge that triggers haptic vibration on the drifted member's phone.
- Interactive itinerary: Search places via Geoapify (Vietnamese-friendly confidence scoring) with Photon / OpenStreetMap fallback, set planned times & notes, and reorder stops on the fly.
- One-sentence AI itinerary: Describe your vibe in one sentence →
POST /api/suggest-routegenerates 3–5 geocoded stops using any OpenAI-compatible model (DeepSeek, Kimi/Moonshot, OpenRouter) or Anthropic Claude (gracefully falls back to a curated Saigon route when unconfigured). - Arrival geofencing & auto-advance: Tracks live members within 50 m of the active stop and automatically advances to the next stop once ≥ 80% of live members arrive.
- When signal drops in dense crowds or underground passages, GPS continues recording into IndexedDB (
tagalong / pending_locations). - Once connectivity returns, queued points are drained in chronological order and backfilled in batches to preserve an unbroken route history.
- In-session group chat: Real-time text messages, one-tap quick replies, and automated system event messages.
- Post-outing Recap (
/s/<code>/recap& public/r/<code>): Replay everyone's walked path, inspect outing stats, and export a shareable dark-map recap image (server-proxied via/api/static-mapso the canvas stays untainted and API keys never leak). - Installable PWA: Full Web App Manifest (
src/app/manifest.ts), dynamic SVG/PNG app icons (/icons/[size]), and Service Worker (public/sw.js).
flowchart TB
subgraph Client["Phone / Browser PWA (Next.js 15 + React 19 + MapLibre GL)"]
UI["Tagalong Dark Pulse UI\n(Lobby · Live Map · Pocket Mode · Chat · Recap)"]
HOOK["useLiveSession Hook"]
CORE["Pure Domain Engine (src/lib/)\nadaptive · separation · stops · presence · geo"]
IDB[("IndexedDB\nOffline GPS Queue")]
APIS["Browser APIs\nGeolocation · Wake Lock · Battery · Vibration · Notifications"]
end
subgraph Server["Next.js App Router API (Vercel)"]
AI_API["POST /api/suggest-route\n(AI + Geoapify / Photon · 10 req/IP/day)"]
MAP_API["GET /api/static-map\n(Same-origin Geoapify Dark Proxy · 30 req/IP/day)"]
end
subgraph Backend["Supabase Cloud"]
RT["Supabase Realtime\nLive Broadcast & Presence"]
PG[("PostgreSQL + 100% RLS\n6 Tables · pg_cron 24h Auto-Purge")]
AUTH["Supabase Auth\nAnonymous & Google OAuth"]
end
APIS --> HOOK
HOOK <--> CORE
HOOK <-->|"Offline buffer & backfill"| IDB
HOOK <--> UI
HOOK <--> RT
HOOK <--> PG
UI --> AUTH
UI --> AI_API
UI --> MAP_API
All core algorithms live as deterministic, UI-independent pure functions under src/lib/ and are covered by 20 Vitest unit tests (src/lib/__tests__/logic.test.ts):
| Module | Core Algorithm & Constants | Why it matters |
|---|---|---|
adaptive.ts |
4 s send interval when moving (≥ 0.7 m/s) or near edge (> 70% of threshold); 30 s when stationary; instant send on ≥ 15 m jump (min 2 s gap) |
Cuts battery & data drain while staying responsive when someone starts drifting |
separation.ts |
Median group center · 30 s dwell debounce · 5 min cooldown · +100 m escalation · ignores stale / left_app / hidden |
Eliminates noisy false alarms from urban GPS drift and alert fatigue |
stops.ts |
50 m arrival geofence radius · auto-advance at ≥ 80% live member arrival · immutable moveStop reorder |
Keeps the itinerary moving smoothly without manual host babysitting |
presence.ts |
60 s heartbeat timeout (STALE_AFTER_MS) separating live, stale, left_app, hidden, unknown |
Gives friends honest signal visibility instead of frozen pins |
offlineQueue.ts |
IndexedDB enqueue / chronological drain / pendingCount per session |
Preserves full outing path through temporary dead zones |
placeMatch.ts |
Confidence-ranked Vietnamese geocoding match (Geoapify primary → Photon/OSM backup) |
Accurately resolves local landmarks & street-food spots from AI suggestions |
Tagalong enforces privacy at the database layer, not just in frontend UI code (supabase/migrations/0001_init.sql):
- Row Level Security (RLS) enabled on all 6 tables:
sessions&stops— readable by code for joining; writable only by the session owner (public.is_owner).members— self-join enforces< 20active members and blocks joiningendedsessions.locations&messages— strictly scoped to verified members of that session (public.is_member).recaps— public read via uniqueshare_slug, containing only aggregated outing stats (never raw PII).
- Automated 24-Hour Data Purge (
pg_cron):- Hourly job (
tagalong-retention, scheduled at minute:17every hour) automatically marks expired sessions asendedand permanently deletes rawlocationsandmessages24 hours afterends_at.
- Hourly job (
- Zero Client Secret Exposure:
- AI keys (
AI_API_KEY/ANTHROPIC_API_KEY) andGEOAPIFY_API_KEYexist exclusively in server-side Route Handlers with per-IP daily rate limits.
- AI keys (
| Route | Purpose |
|---|---|
/ |
Landing screen + instant "Xem demo" entry |
/login |
Display-name anonymous sign-in or Google OAuth |
/home |
Join a session by 6-digit code, view active/recent outings |
/create |
Create a new outing, configure radius/duration & build multi-stop route (with AI assist) |
/s/[code] |
Live session: lobby, MapLibre live view, separation banners, chat & Pocket Mode |
/s/[code]/recap |
Member recap with animated path replay & downloadable dark-map share card |
/r/[code] |
Public read-only recap share page |
| Method | Endpoint | Rate Limit | Description |
|---|---|---|---|
POST |
/api/suggest-route |
10 req / IP / day | Turns a 1-sentence outing prompt into 3–5 geocoded stops (OpenAI-compatible / Anthropic / Saigon sample fallback) |
GET |
/api/static-map |
30 req / IP / day | Same-origin proxy to Geoapify Dark Matter Static Maps (24h cache) for untainted canvas recap exports |
| Layer | Technologies |
|---|---|
| Framework & UI | Next.js 15 (App Router) · React 19 · TypeScript (strict) · Tailwind CSS 4 · Zustand · @fontsource-variable/inter |
| Maps & Geocoding | MapLibre GL 6 · CARTO Dark Matter tiles · Geoapify Geocoding & Static Maps · Photon / OpenStreetMap |
| Backend & Realtime | Supabase (PostgreSQL, Realtime, Anonymous & Google Auth, Row Level Security, pg_cron) |
| AI Route Assistant | Any OpenAI-compatible API (DeepSeek, Kimi/Moonshot, OpenRouter) or Anthropic Claude API |
| Native Web APIs | Geolocation · Screen Wake Lock · Battery Status · Web Notifications · Vibration · IndexedDB · Service Worker |
| Quality & CI | Vitest (20 unit tests) · ESLint 9 · TypeScript tsc --noEmit · GitHub Actions CI · Vercel |
git clone https://github.com/VectorNguyen/tagalong.git
cd tagalong
npm install
npm run dev # http://localhost:3000
predevandprebuildautomatically copy the MapLibre Web Worker viascripts/copy-maplibre-worker.mjs. With no.envconfigured, demo mode works immediately out of the box.
npm test # 20 unit tests (geo, separation, stops, adaptive, presence)
npm run lint && npm run typecheck && npm run buildEnvironment Variables (.env.example)
| Variable | Scope | Required | Description |
|---|---|---|---|
NEXT_PUBLIC_SUPABASE_URL |
Client + Server | Multi-device | Supabase Project URL (omit for browser demo mode) |
NEXT_PUBLIC_SUPABASE_ANON_KEY |
Client + Server | Multi-device | Supabase anon public key |
NEXT_PUBLIC_ENABLE_GOOGLE |
Client | Optional | Set 1 after enabling Google OAuth in Supabase |
AI_API_KEY, AI_BASE_URL, AI_MODEL |
Server only | Optional | Any OpenAI-compatible endpoint (DeepSeek, Kimi, OpenRouter…) |
ANTHROPIC_API_KEY, ANTHROPIC_MODEL |
Server only | Optional | Anthropic Messages API (fallback if AI_API_KEY is unset) |
GEOAPIFY_API_KEY |
Server only | Optional | Vietnamese geocoding boost & dark basemap for recap image export |
NEXT_PUBLIC_MAP_STYLE_URL |
Client | Optional | Custom MapLibre style URL (defaults to CARTO Dark Matter) |
Step-by-step: Deploy Multi-Device Production (Vercel + Supabase)
- Import
VectorNguyen/tagalongon Vercel and deploy — demo mode is live immediately. - Create a Supabase project and execute
supabase/migrations/0001_init.sqlandsupabase/migrations/0002_members_select_own.sqlin order inside the SQL Editor. - In Supabase → Authentication → Sign In / Providers, enable Anonymous Sign-Ins. Under URL Configuration, set Site URL to your Vercel domain and add
https://<your-app>.vercel.app/**to Redirect URLs. - Add
NEXT_PUBLIC_SUPABASE_URLandNEXT_PUBLIC_SUPABASE_ANON_KEYin Vercel → Project Settings → Environment Variables, then Redeploy. - (Optional) Enable Google Login in Supabase and set
NEXT_PUBLIC_ENABLE_GOOGLE=1. - (Optional) Configure
AI_API_KEY+AI_BASE_URL+AI_MODEL(orANTHROPIC_API_KEY) for real AI route suggestions, andGEOAPIFY_API_KEY(free tier atmyprojects.geoapify.com) for high-accuracy Vietnamese place search + dark-map recap exports.
tagalong/
├── src/
│ ├── app/
│ │ ├── page.tsx, login/, home/, create/ # Onboarding & outing setup
│ │ ├── s/[code]/ & s/[code]/recap/ # Live session & member recap
│ │ ├── r/[code]/ # Public recap share page
│ │ ├── api/suggest-route/ & api/static-map/ # Server-only AI & static map proxies
│ │ └── manifest.ts & icons/[size]/ # PWA manifest & generated app icons
│ ├── components/
│ │ ├── MapView.tsx, RouteEditor.tsx, RecapView.tsx, RegisterSW.tsx
│ │ └── live/ # LiveScreen, Lobby, Overlays, Panels
│ ├── hooks/ # useLiveSession (core orchestrator), useProfile
│ └── lib/ # Pure geospatial/domain modules + 20 unit tests
├── supabase/migrations/ # 6-table schema, RLS policies, 24h pg_cron cleanup
├── public/sw.js # PWA Service Worker
├── scripts/copy-maplibre-worker.mjs # MapLibre worker asset helper
└── docs/SRS.md # Full Software Requirements Specification
- True Background GPS Tracking: Mobile browsers pause geolocation when the screen locks. v1 mitigates this via Pocket Mode (Wake Lock), IndexedDB offline backfill, and honest
left_appstates; native background tracking is planned via Capacitor (#36). - Web Push Notifications: Alert members even when the browser tab is closed (requires Add-to-Home-Screen on iOS Safari).
- RLS-Scoped Private Realtime Channels: Upgrade from per-code broadcast channels to Supabase Realtime Authorization with private RLS channels.
Thắng Nguyễn · @VectorNguyen
Conceived, designed in Figma, specified (SRS), engineered, and shipped solo.