How ynotfins/nfa-alerts-enterprise works
Purpose and active entry points
NFA Alerts Enterprise is an emergency-response monorepo. Its production implementation is a mobile-first Next.js PWA; Android and iOS are placeholders. Web UI enters through apps/web/src/app/layout.tsx, apps/web/src/app/page.tsx, and route groups under apps/web/src/app/(auth) and apps/web/src/app/(dashboard). Server endpoints are Next route handlers under apps/web/src/app/api.
Runtime and deployment boundary
The active runtime is TypeScript/Next.js, deployed as a PWA with service workers and manifest assets in apps/web/public/sw.js, apps/web/public/firebase-messaging-sw.js, and apps/web/public/manifest.json. Deployment settings are in apps/web/vercel.json; repo automation includes scripts/next-build.mjs and scripts/vps-deploy.sh. Firebase project nfa-alerts-v2 is the backend boundary.
Authentication, identity, and authorization
Firebase Auth-backed client/server authentication is separated into apps/web/src/lib/auth-client.ts, apps/web/src/lib/server-auth.ts, and apps/web/src/contexts/auth-context.tsx. The signup flow gathers credentials, profile, legal acceptance, and signature through apps/web/src/app/(auth)/signup/page.tsx, apps/web/src/app/(auth)/signup/profile/page.tsx, and apps/web/src/app/(auth)/signup/signature/page.tsx. Dashboard access and role-sensitive experience are organized beneath apps/web/src/app/(dashboard)/layout.tsx, with profile boundary logic in apps/web/src/lib/profile-boundary.ts.
Incident-response domain
Incidents are the primary operational workflow: listing/filtering, detail, homeowner information, documents/photos, and signing. Route composition lives under apps/web/src/app/(dashboard)/incidents/page.tsx, apps/web/src/app/(dashboard)/incidents/[id]/layout.tsx, and apps/web/src/app/(dashboard)/incidents/[id]/sign/page.tsx. Domain persistence and business operations are concentrated in apps/web/src/services/incidents.ts, with validation contracts in apps/web/src/schemas/incident.ts and document generation in apps/web/src/lib/pdf-generator.ts.
Realtime coordination and communications
Firestore/Firebase client integrations support profiles, live presence/location, chat, and notifications via apps/web/src/lib/firebase.ts, apps/web/src/lib/firebase-db.ts, and apps/web/src/lib/db.ts. Chat is exposed through apps/web/src/app/(dashboard)/chat/[threadId]/page.tsx, client state in apps/web/src/hooks/use-chat.ts, and service operations in apps/web/src/services/chat.ts. Chaser discovery and routing are separate dashboard capabilities in apps/web/src/app/(dashboard)/chasers/page.tsx and apps/web/src/app/(dashboard)/route/page.tsx; Google Maps is encapsulated by apps/web/src/components/google-map.tsx.
Ingestion, notifications, and external APIs
The externally sensitive ingestion boundary is apps/web/src/app/api/webhook/route.ts, supported by parsing, geocoding, and error modules in apps/web/src/lib/webhook/parser.ts, apps/web/src/lib/webhook/geocoder.ts, and apps/web/src/lib/webhook/errors.ts. Push delivery crosses Firebase Admin and FCM through apps/web/src/lib/firebase-admin.ts, apps/web/src/app/api/notifications/send/route.ts, and apps/web/src/components/push-notification-provider.tsx. Weather is served through apps/web/src/app/api/weather/route.ts.
Data governance and administration
Firebase is governed as infrastructure, not embedded solely in app code: Firestore rules/indexes and Storage rules are in firebase/firestore.rules, firebase/firestore.indexes.json, and firebase/storage.rules. Administrative user and location management live in apps/web/src/app/(dashboard)/admin/users/page.tsx and apps/web/src/app/(dashboard)/admin/locations/page.tsx; operational repair endpoints reside under apps/web/src/app/api/admin.
Main entry points: firebase.ts Firebase services · (dashboard)/layout.tsx Dashboard boundary · incidents.ts Incident operations · app/layout.tsx App shell
Components 19
Next.js PWA
Primary production runtime.
- App shell
apps/web/src/app/layout.tsx - Auth and signup · Collects credentials, profile, legal acceptance, and signature.
apps/web/src/app/(auth)/signup/page.tsx - Dashboard boundary · Enforces dashboard and role-sensitive experience.
apps/web/src/app/(dashboard)/layout.tsx - PWA runtime
apps/web/public/sw.js - Auth state
apps/web/src/contexts/auth-context.tsx - Server auth
apps/web/src/lib/server-auth.ts - Incident webhook · External ingestion boundary with parsing and geocoding.
apps/web/src/app/api/webhook/route.ts - Push notifications · Sends FCM notifications to PWA clients.
apps/web/src/app/api/notifications/send/route.ts - Administration · Manages users, locations, and operational repairs.
apps/web/src/app/(dashboard)/admin/users/page.tsx
Operational workflows
- Incidents UI · Lists, details, documents, and incident signing.
apps/web/src/app/(dashboard)/incidents/page.tsx - Incident operations
apps/web/src/services/incidents.ts - Incident contracts
apps/web/src/schemas/incident.ts - PDF generation
apps/web/src/lib/pdf-generator.ts - Realtime chat · UI state and service operations for incident communication.
apps/web/src/hooks/use-chat.ts - Chaser routing · Discovery and route planning for responders.
apps/web/src/app/(dashboard)/route/page.tsx
Firebase backend
Project nfa-alerts-v2.
- Firebase services · Auth, Firestore, Storage, presence, and FCM.
apps/web/src/lib/firebase.ts - Firebase Admin
apps/web/src/lib/firebase-admin.ts - Firestore governance · Rules and indexes govern backend data access.
firebase/firestore.rules
External integrations
- Google Maps
apps/web/src/components/google-map.tsx
Connections 22
- App shell → Auth and signup: serves
- App shell → Dashboard boundary: serves
- App shell → PWA runtime: installs
- Auth and signup → Auth state: signs in
- Auth state → Firebase services: uses Auth
- Dashboard boundary → Server auth: verifies access
- Server auth → Firebase Admin: verifies tokens
- Incidents UI → Incident operations: operates incidents
- Incident operations → Incident contracts: validates
- Incident operations → PDF generation: generates documents
- Incident operations → Firebase services: persists
- Realtime chat → Firebase services: realtime data
- Chaser routing → Firebase services: presence and locations
- Chaser routing → Google Maps: renders routes
- Incident webhook → Incident operations: creates or updates
- Push notifications → Firebase Admin: sends via FCM
- Firebase Admin → Firebase services: admin access
- Firebase services → Firestore governance: enforced by
- Administration → Firebase services: manages data
- Dashboard boundary → Incidents UI: hosts
- Dashboard boundary → Realtime chat: hosts
- Dashboard boundary → Chaser routing: hosts