Real-time disaster awareness & emergency SOS β in your pocket.
A mobile-first web app that keeps people informed during disasters with live alerts, an interactive map, AI-generated safety guidance, and a one-tap SOS flow β plus a responder dashboard for emergency teams to triage incoming requests.
| Feature | What it does | |
|---|---|---|
| πΊοΈ | Live disaster map | Leaflet-based map showing alert zones, your location, and a personalized alert radius. |
| π | Real-time alerts feed | Severity/distance filters, relative timestamps, and live updates via Supabase Realtime β no refresh needed. |
| π | One-tap SOS | Signed-in users submit an SOS with severity, message, coordinates, and an optional photo (Supabase Storage). |
| π€ | AI safety guidance | Alerts are turned into short, calm, actionable summaries by Groq (Llama 3.3 70B) via a secure server function. |
| π | Responder dashboard | Staff-only triage board: Active β Reviewing β Resolved, with AI-written situation notes. |
| π | Full auth | Email/password and Google OAuth through Supabase Auth, with automatic profile + preference creation. |
| βοΈ | Personal preferences | Alert radius, minimum severity, push/sound toggles, and location sharing β stored per user. |
| π² | PWA notifications | Installable web app with a service worker for background disaster notifications, including sound cues. |
| π | Geolocation-aware | Distance-sorted alerts and user-position radius filtering everywhere it matters. |
| Route | Screen |
|---|---|
/ |
Home β live status dashboard |
/map |
Interactive disaster map with alert zones |
/alerts |
Real-time alert feed with filters |
/sos |
Emergency SOS submission flow |
/responder |
Staff-only emergency responder dashboard |
/settings |
Account, preferences, sign out |
/auth |
Sign in / sign up / Google OAuth |
- Framework β TanStack Start (React 19, file-based routing, SSR) with TanStack Router + Query
- Hosting β Cloudflare Workers (SSR served from the edge via
wrangler) - Backend β Supabase: Postgres, Auth, Realtime, Storage β no custom REST API needed
- AI β Groq
llama-3.3-70b-versatilebehind a TanStack server function (API key never reaches the browser) - UI β Tailwind CSS v4, shadcn-style components on Radix primitives, Framer Motion, Lucide icons, Sonner toasts
- Maps β Leaflet + react-leaflet (lazy-loaded client-side)
- Notifications β Service worker (
public/alertify-sw.js) + PWA manifest for push-style alerts and sounds
flowchart TB
subgraph browser [Browser]
R[TanStack Router + React 19]
SW[Service worker / PWA]
SB[Supabase JS client]
end
subgraph cf [Cloudflare Worker]
S[src/server.ts - Worker fetch handler]
T[TanStack Start SSR]
AI[Server function β Groq AI]
end
subgraph supa [Supabase]
DB[(Postgres + RLS)]
RT[Realtime]
ST[Storage - sos-images]
AU[Auth]
end
User --> R
R -->|"GET /route"| S --> T --> R
R --> AI
R <--> SB
SB --> DB & RT & ST & AU
SW -->|"notifications"| R
- The Worker receives
GET /β¦and hands it to TanStack Start for SSR β HTML streams back, then the app hydrates. - The browser talks to Supabase directly for reads, writes, auth, storage, and realtime subscriptions β protected by Row Level Security.
- AI summaries run through a server function so
GROQ_API_KEYstays server-side.
git clone https://github.com/animatrix01/alertify.ai.git
cd alertify.ai
npm installRun the migrations against your Supabase project:
supabase link --project-ref <your-project-ref>
supabase db pushThis creates all tables, RLS policies, triggers, enums, the sos-images storage bucket, and enables Realtime on disaster_alerts and sos_reports.
In the Supabase dashboard, also enable the Google OAuth provider if you want Google sign-in.
Create a .env file in the project root:
# Browser (Vite build-time)
VITE_SUPABASE_URL=https://<your-project-ref>.supabase.co
VITE_SUPABASE_PUBLISHABLE_KEY=<your-anon-key>
# Server (SSR / Cloudflare Worker)
SUPABASE_URL=https://<your-project-ref>.supabase.co
SUPABASE_PUBLISHABLE_KEY=<your-anon-key>
GROQ_API_KEY=<your-groq-api-key> # optional β app degrades gracefully without it
# Local dev only (service worker is disabled in dev by default)
VITE_ENABLE_SW=1
β οΈ SUPABASE_SERVICE_ROLE_KEYis supported for the server-only admin client (src/integrations/supabase/client.server.ts) and bypasses RLS β never expose it to the browser.
There is no automated ingestion pipeline yet β the disaster_alerts table only contains what you insert. To see the map and alerts feed populated, insert a few test rows (Supabase SQL editor or supabase db execute):
insert into public.disaster_alerts (type, severity, title, description, latitude, longitude, radius_km, source, expires_at) values
('flood', 'critical', 'Flash flood warning', 'Rapid water level rise along the river. Move to higher ground immediately.', 28.6139, 77.2090, 15, 'test', now() + interval '12 hours'),
('earthquake','warning', 'M5.4 seismic event', 'Moderate shaking reported. Check for structural damage before re-entering buildings.', 35.6895, 139.6917, 50, 'test', now() + interval '6 hours'),
('wildfire', 'advisory', 'Wildfire spreading NW', 'Smoke visible from town. Keep windows closed and monitor local guidance.', 37.7749, -122.4194, 25, 'test', now() + interval '24 hours');They'll appear on the map and feed instantly thanks to the Realtime subscription.
npm run dev # start the dev serverOpen the printed local URL (typically http://localhost:5173) on desktop or a phone β the UI is mobile-first.
| Symptom | Cause & fix |
|---|---|
Missing Supabase environment variable(s) thrown at startup |
One of VITE_SUPABASE_URL / VITE_SUPABASE_PUBLISHABLE_KEY isn't set. Copy .env.example β .env and restart the dev server. |
Map page blank or SSR error mentioning window |
Leaflet only runs in the browser β it's lazy-loaded on /map. If you add new map components, keep them client-only (mount after hydration). |
| No notification prompts / sounds in dev | The service worker is disabled in dev so it doesn't fight HMR. Set VITE_ENABLE_SW=1 and restart. |
| Google sign-in fails or redirects to an error | Enable the Google provider in Supabase Auth settings and add your app URL to the allowed redirect URLs. |
| Alerts feed is empty | Nothing ingests alerts automatically β see step 4 to insert sample data. |
| AI summaries show the raw description | GROQ_API_KEY isn't set (or is invalid). Without it the app degrades gracefully to the original alert text. |
| Command | What it does |
|---|---|
npm run dev |
Start the Vite dev server |
npm run build |
Production build (Cloudflare Worker output) |
npm run build:dev |
Production build in development mode |
npm run preview |
Preview the production build locally |
npm run lint |
Run ESLint |
npm run format |
Format with Prettier |
The repo is already wired for Workers (wrangler.jsonc β main: src/server.ts):
npx wrangler deploySet your production environment variables (SUPABASE_URL, SUPABASE_PUBLISHABLE_KEY, GROQ_API_KEY) as Worker secrets:
npx wrangler secret put SUPABASE_URL
npx wrangler secret put SUPABASE_PUBLISHABLE_KEY
npx wrangler secret put GROQ_API_KEYalertify.ai/
βββ src/
β βββ routes/ # File-based routes (/, /map, /alerts, /sos, /responder, /settings, /auth)
β βββ components/
β β βββ layout/ # AppShell, TopBar, BottomNav
β β βββ map/ # Leaflet disaster map
β β βββ notifications/ # Alert notification manager
β β βββ settings/ # Settings components
β β βββ ui/ # shadcn-style UI primitives
β βββ hooks/ # Auth, geolocation, alerts, preferences, SOS, staff roleβ¦
β βββ services/
β β βββ ai/ # Groq AI alert summaries (server function)
β β βββ notifications/ # Service worker registration, sounds, dedupe, severity priority
β βββ integrations/supabase/ # Typed client, admin client, auth middleware, generated types
β βββ lib/ # Utilities, SSR error handling
β βββ server.ts # Cloudflare Worker entry
β βββ start.ts # TanStack Start instance + server middleware
β βββ styles.css # Tailwind v4 + theme tokens
βββ supabase/migrations/ # SQL schema, RLS policies, triggers, realtime, storage
βββ public/
β βββ alertify-sw.js # Service worker for notifications
β βββ manifest.webmanifest # PWA manifest
β βββ sounds/ # Alert sound cues
β βββ images/
βββ wrangler.jsonc # Cloudflare Workers config
| Table | Purpose | Access |
|---|---|---|
disaster_alerts |
Live disaster alerts (type, severity, location, radius, expiry) | Public read, Realtime-enabled |
sos_reports |
Emergency SOS submissions with status lifecycle | Owner-only (RLS) |
profiles |
User display name, avatar, phone, role | Owner-only |
user_preferences |
Alert radius, min severity, push/sound/location toggles | Owner-only |
emergency_contacts |
Personal emergency contact list | Owner-only |
sos-images (bucket) |
Optional SOS photo attachments | Public read, owner write |
Enums: alert_severity (info β advisory β warning β critical), alert_type (earthquake, flood, wildfire, storm, tsunami, heatwave, landslide, other), sos_status (active β acknowledged β resolved / cancelled).
A handle_new_user trigger automatically creates a profile and default preferences for every new signup.
- Row Level Security is enabled on every table β clients only ever read/write their own rows, and alerts are read-only.
- The Groq API key lives only in a server function; the client gets the generated text back, never the key.
- The service-role key is never shipped to the browser; use it only for trusted server-side operations.
- Responder access is checked via the
useStaffRolehook (email allow-list for the demo +profiles.rolefor future RBAC).
- Automated disaster-feed ingestion (USGS, GDACS, etc.) into
disaster_alerts - Web Push for off-screen disaster notifications
- Responder assignment + ETA tracking on active SOS reports
- Emergency contacts integration into the SOS flow
- Full RBAC UI for responder/admin management
All rights reserved Β© 2026 Alertify.
For a full tour of how the codebase is wired β request flow, auth middleware, HTTP endpoints, and the mental model of every layer β see final project overview.md.
Built with β€οΈ to help people stay safe when it matters most.