How krishnn24/safe-her-pbl-project-work- works
1. Repository shape
- SafeHer is a Vite + React + TypeScript frontend app with a Capacitor Android wrapper and a Supabase backend.
- The README confirms the current emphasis is web-first: most product flows exist in the frontend, while backend enforcement and native capabilities are still being filled in.
2. Primary runtime layers
- The app runs as a browser SPA built from src/main.tsx and src/App.tsx.
- A native Android shell exists under android/, but it is currently a wrapper around the web app rather than a separate native product.
- Deployment is likely web-hosted (there is a vercel.json), with Android packaging handled through Capacitor/Gradle.
3. Navigation and page boundaries
- Top-level screens live in src/pages: Index, Auth, Dashboard, ResetPassword, and NotFound.
- This implies a clear boundary between:
- public marketing/entry experience,
- authentication flows,
- authenticated safety dashboard,
- password recovery.
- The main app likely routes users between these page-level shells and then composes feature sections inside them.
4. Feature-oriented UI composition
- The UI is organized as reusable sections under src/components, especially:
- landing/content sections like HeroSection, FeaturesSection, SecuritySection, FAQSection, TestimonialsSection, Footer, Navbar,
- safety workflow components under sos/,
- dashboard modules under dashboard/,
- auth helpers under auth/.
- This indicates a mostly section-based architecture rather than deeply nested domain services in the UI layer.
5. SOS and emergency workflow subsystem
- The most important domain boundary is the SOS system, centered around:
- SOSButton, SOSConfirmationDialog, SOSActiveOverlay, PatternLockOverlay, ShakeDetector,
- SOSContext,
- services such as sosService, emergencyMessageService, and shakeDetectionService.
- The architecture suggests emergency actions originate from UI gestures or sensors, flow through shared SOS state, and then fan out into alert creation, recording, messaging, and location capture.
6. Sensor and discreet-trigger support
- The app includes hooks/services for sensor-driven triggers: useShakeDetection, ShakeDetector, and shakeDetectionService.
- PatternLockOverlay indicates a discreet pattern-based activation path.
- useAudioRecorder and discreteRecordingService show planned or partial support for audio capture during emergencies, likely intended to integrate more fully once native mobile capabilities are available.
7. Location and safety context
- useGeolocation and locationTrackingService provide the location subsystem.
- Dashboard components like PoliceStationLocatorSection, PoliceStationMap, and PoliceStationList indicate the app is not only tracking the user, but also surfacing nearby assistance points.
- This creates a data flow from device location into dashboard UI and emergency workflows, with location being part of the SOS payload rather than just a standalone feature.
8. User account and settings domain
- Authentication and user management are handled through useAuth, ProtectedRoute, and pages like Auth and ResetPassword.
- useUserSettings and dashboard sections such as ProfileSettingsSection, TrustedContactsSection, and SOSAlertsSection suggest user-specific configuration is part of the authenticated experience.
- The TrustedContactsSection is a key data boundary: it likely feeds both alert routing and emergency notification recipients.
9. Supabase as backend boundary
- Backend integration is centered on src/integrations/supabase/client.ts and generated types.ts.
- The presence of supabase/migrations indicates the data model lives in Supabase SQL migrations, with schema evolution managed alongside the frontend.
- supabase/functions/trigger-sos is the main server-side executable shown in the repo, likely used for emergency-event orchestration or notification triggering.
- The README notes that RLS is intended, so access control is part of the backend boundary even if still in progress.
10. Shared UI and design system
- The src/components/ui directory is a large shadcn/ui-style component library: dialogs, forms, tabs, tables, toasts, etc.
- This is a shared presentation layer used across landing pages, authentication, and dashboard features.
- It helps keep the domain sections thin and makes the repository’s architecture more composition-driven than framework-specific.
11. Cross-cutting hooks and utilities
- Common behavior is factored into hooks such as use-mobile, use-toast, useAudioRecorder, useGeolocation, useShakeDetection, and useUserSettings.
- Utility code is concentrated in src/lib, including passwordValidation and shared helpers.
- These are the main reuse points that connect feature sections to browser APIs, device capabilities, and UI feedback.
12. Native mobile boundary
- The android/ project is a standard Gradle/Android app scaffold produced for Capacitor.
- MainActivity.java, AndroidManifest.xml, and file_paths.xml show the app is already prepared for native packaging and file-access capabilities, but the README makes clear native behavior is still planned/in progress.
- Architecturally, Android is a delivery shell around the web app rather than the primary business-logic host.
13. Operational and build tooling
- The repo is built with Vite, TypeScript, Tailwind CSS, ESLint, and PostCSS.
- capacitor.config.ts, vite.config.ts, and tailwind.config.ts define the main build/runtime boundaries.
- The existence of Bun and npm lockfiles suggests the project has been iterated with multiple package managers, but that does not change the runtime architecture.
14. Overall data flow
- A user enters through the public pages, authenticates, and reaches the dashboard.
- From the dashboard or SOS overlays, the user can trigger an emergency flow via button, pattern, or shake.
- That flow gathers context such as location, trusted contacts, and optional recording, then hands off to Supabase-backed persistence/processing and the trigger-sos edge function.
- The architecture is therefore a frontend-driven safety workflow with backend services increasingly taking over persistence, authorization, and notification responsibilities.
Main entry points: App.tsx App · Dashboard.tsx Dashboard · Index.tsx Home · sosService.ts SOS Service
Components 32
Web App
Vite + React SPA entry, routing, and page shells.
- Main · Bootstraps the React application.
src/main.tsx - App · Top-level app composition and route wiring.
src/App.tsx - Home · Public entry and marketing experience.
src/pages/Index.tsx - 404 · Unknown-route fallback.
src/pages/NotFound.tsx - Navbar · Top-level site navigation.
src/components/Navbar.tsx - Hero · Primary landing-page call to action.
src/components/HeroSection.tsx - Features · Product feature overview.
src/components/FeaturesSection.tsx - Security · Trust and safety positioning.
src/components/SecuritySection.tsx
SOS System
Emergency trigger, sensor, and alert workflow.
- SOS Context · Shared emergency state and coordination point.
src/contexts/SOSContext.tsx - SOS Button · Primary emergency activation control.
src/components/sos/SOSButton.tsx - Active Overlay · In-progress emergency screen.
src/components/sos/SOSActiveOverlay.tsx - Pattern Lock · Secret activation interface.
src/components/sos/PatternLockOverlay.tsx - Shake Detector · Device-motion trigger listener.
src/components/sos/ShakeDetector.tsx - SOS Service · Orchestrates emergency event creation.
src/services/sosService.ts - Message Service · Builds emergency messages and notification content.
src/services/emergencyMessageService.ts - Location Service · Captures and tracks location for emergencies.
src/services/locationTrackingService.ts - Recording Service · Discrete audio capture support for incidents.
src/services/discreteRecordingService.ts
Account & Dashboard
Authenticated user experience and safety settings.
- Auth · Sign-in and sign-up flow.
src/pages/Auth.tsx - Dashboard · Authenticated safety workspace.
src/pages/Dashboard.tsx - Reset · Password reset flow.
src/pages/ResetPassword.tsx - Auth Hook · Client authentication state and helpers.
src/hooks/useAuth.ts - Protected Route · Blocks unauthenticated access to private pages.
src/components/auth/ProtectedRoute.tsx - Settings · User profile and preferences management.
src/components/dashboard/ProfileSettingsSection.tsx - Contacts · Trusted contact management.
src/components/dashboard/TrustedContactsSection.tsx - SOS Alerts · Emergency alert history and status.
src/components/dashboard/SOSAlertsSection.tsx - Police Locator · Nearby assistance discovery.
src/components/dashboard/PoliceStationLocatorSection.tsx
Supabase
Database, auth boundary, migrations, and edge function.
- Supabase Client · Frontend database/auth integration point.
src/integrations/supabase/client.ts - Supabase Types · Typed schema bindings for backend data.
src/integrations/supabase/types.ts - Trigger SOS · Server-side emergency orchestration entrypoint.
supabase/functions/trigger-sos/index.ts - Migrations · Supabase schema and access control evolution.
supabase/migrations/20251208132143_6b4787d5-b612-4b60-afae-5998ab4c44aa.sql
Android Shell
Capacitor-wrapped Android delivery project.
- Main Activity · Capacitor Android host activity.
android/app/src/main/java/com/safeher/app/MainActivity.java - Manifest · Android app configuration and entry metadata.
android/app/src/main/AndroidManifest.xml
Connections 31
- Main → App: boots · Application startup loads the top-level app shell.
- App → Home: routes · Public landing route.
- App → Auth: routes · Authentication route.
- App → Dashboard: routes · Authenticated dashboard route.
- App → Reset: routes · Password recovery route.
- App → 404: fallback · Unhandled routes land here.
- Home → Navbar: composes · Landing page uses shared navigation.
- Home → Hero: composes · Landing page feature entry.
- Home → Features: composes · Landing feature overview.
- Home → Security: composes · Trust and safety section.
- App → Protected Route: guards · Private routes are wrapped by auth protection.
- Protected Route → Dashboard: permits · Authenticated users reach the dashboard.
- Auth → Auth Hook: uses · Authentication UI depends on auth state.
- Dashboard → Settings: composes · Profile configuration section.
- Dashboard → Contacts: composes · Trusted contacts section.
- Dashboard → SOS Alerts: composes · Alert history and status section.
- Dashboard → Police Locator: composes · Nearby assistance locator section.
- SOS Button → SOS Context: updates · Activation state flows through shared SOS context.
- Pattern Lock → SOS Context: updates · Discreet activation also feeds SOS state.
- Shake Detector → SOS Context: updates · Sensor trigger feeds emergency state.
- SOS Context → SOS Service: orchestrates · Shared state launches emergency workflow.
- SOS Service → Message Service: builds · Emergency message content is prepared.
- SOS Service → Location Service: includes · Location context is collected for alerts.
- SOS Service → Recording Service: includes · Optional incident recording is captured.
- SOS Service → Supabase Client: persists · Emergency events and related data use Supabase.
- Supabase Client → Supabase Types: typed by · Backend schema bindings drive client types.
- Trigger SOS → Migrations: backed by · Edge function operates on the Supabase schema.
- Dashboard → Supabase Client: loads · Dashboard sections read backend data.
- Auth Hook → Supabase Client: authenticates · Auth hook depends on Supabase auth/client APIs.
- Main Activity → Manifest: declared in · Android entrypoint is configured by the manifest.
- Main Activity → App: hosts · Android shell wraps the web app.