How anto-remy/remy-care-connect works
Purpose and Runtime
Remy Care Connect is a role-based maternal-health frontend for mothers, community health workers (CHWs), nurses, and facility staff. It provides registration/authentication, care monitoring, assignments, escalations, appointments, and notifications. The browser SPA is built with React/TypeScript and Vite; Tailwind/PostCSS support styling. The stated backend boundary is a FastAPI/PostgreSQL service, accessed from the frontend rather than present in this repository.
Entry points: src/main.tsx, src/App.tsx, and index.html.
Application Composition and Routing
App.tsx is the application shell and route composition point. Page-level entry routes separate public landing/auth flows from role-specific application surfaces:
• Public and role selection: src/pages/LandingPage.tsx, src/pages/Login.tsx, src/pages/RoleSelector.tsx
• Mother surfaces: src/pages/MotherIndex.tsx, src/pages/ModernMotherIndex.tsx
• Worker/facility surfaces: src/pages/CHWIndex.tsx, src/pages/NurseIndex.tsx, src/pages/FacilityIndex.tsx
Protected access is enforced at the UI routing boundary by src/components/ProtectedRoute.tsx.
Identity, Roles, and Onboarding
Authentication state is centralized in src/contexts/AuthContext.tsx; API-facing authentication concerns are isolated in src/services/authService.ts and facility-staff-specific auth in src/services/facilityStaffAuthService.ts. Registration is role-specific, including src/pages/RegisterMother.tsx, src/pages/RegisterHealthWorker.tsx, and src/pages/RegisterFacilityAdmin.tsx.
OTP, profile-photo, and role-selection dialogs support the identity/onboarding journey: src/components/VerifyOTPModal.tsx, src/components/PhotoOnboardingModal.tsx, src/components/ui/RoleSelectionModal.tsx.
Role-Specific Care Workflows
Dashboards are the principal operational views, tailored to each actor:
• Mother self-service, pregnancy status, facility discovery/booking: src/components/mother/ModernMotherDashboard.tsx, src/components/mother/PregnancyJourneyTracker.tsx, src/components/mother/FacilityBookingCard.tsx
• CHW caseload and mother monitoring: src/components/chw/EnhancedCHWDashboard.tsx, src/components/chw/CHWProfile.tsx
• Nurse supervisory workflow: src/components/nurse/EnhancedNurseDashboard.tsx, src/components/nurse/NurseProfile.tsx
• Facility operations: src/components/facility/FacilityDashboard.tsx
Shared navigation/layout components establish the authenticated application frame: src/components/layout/Layout.tsx, src/components/layout/Navigation.tsx, src/components/layout/Sidebar.tsx.
Service and API Boundary
Domain services encapsulate calls to the backend, with common client behavior in src/lib/apiClient.ts. Major care-domain boundaries include:
• Mother records and check-ins: src/services/motherService.ts, src/services/checkinService.ts
• CHW assignment and escalation: src/services/assignmentService.ts, src/services/escalationService.ts
• Facility appointments and facility escalations: src/services/appointmentService.ts, src/services/facilityAppointmentService.ts, src/services/facilityEscalationService.ts
• Supporting clinical data: src/services/nutritionService.ts, src/services/weightService.ts, src/services/ultrasoundService.ts
The primary flow is UI/dashboard → domain service → apiClient → FastAPI/PostgreSQL, with responses driving role-specific state and presentation.
Real-Time Notifications and External Services
Socket lifecycle/state is centralized in src/contexts/SocketContext.tsx, backed by src/lib/socketClient.ts; consumers use src/hooks/useSocket.ts and facility-specific src/hooks/useFacilitySocket.ts. This is the real-time boundary for alerts and workflow updates, alongside src/services/notificationService.ts and src/components/ConnectionBanner.tsx.
Firebase is separately integrated through src/lib/firebaseClient.ts; the browser push worker is public/firebase-messaging-sw.js. This implies Firebase Cloud Messaging for push notification delivery, while sockets serve live in-app updates.
UI and Deployment Boundaries
Reusable accessible UI primitives are housed under src/components/ui/, while responsive behavior is concentrated in src/hooks/use-mobile.tsx, src/components/ui/HamburgerButton.tsx, and src/components/ui/MobileMenuPanel.tsx. Build/runtime configuration is Vite-based: vite.config.ts, package.json, and tailwind.config.ts. CI and security automation are defined in .github/workflows/ci.yml and .github/workflows/security.yml.
Main entry points: SocketContext.tsx Socket state · Layout.tsx Authenticated layout · motherService.ts Care domain services · App.tsx App and routes
Components 23
Browser application
React/Vite SPA and role-specific workflows.
- HTML entry
index.html - React bootstrap
src/main.tsx - App and routes · Composes public and role-specific route surfaces.
src/App.tsx - Protected route · Enforces authenticated UI access.
src/components/ProtectedRoute.tsx - Public and auth pages · Landing, login, role selection, and registration.
src/pages/Login.tsx - Auth state · Centralized identity and role state.
src/contexts/AuthContext.tsx - Onboarding dialogs · OTP, photo, and role-selection dialogs.
src/components/VerifyOTPModal.tsx - Mother care UI · Self-service, pregnancy tracking, and facility booking.
src/components/mother/ModernMotherDashboard.tsx - CHW care UI · Caseload and mother monitoring workflow.
src/components/chw/EnhancedCHWDashboard.tsx - Nurse care UI · Supervisory care workflow.
src/components/nurse/EnhancedNurseDashboard.tsx - Facility operations UI
src/components/facility/FacilityDashboard.tsx - Authenticated layout · Navigation frame for signed-in role surfaces.
src/components/layout/Layout.tsx - Push service worker
public/firebase-messaging-sw.js
Frontend service boundary
Domain calls and real-time client integration.
- Care domain services · Mother, check-in, assignment, escalation, appointment, and clinical-data APIs.
src/services/motherService.ts - Authentication services · Authentication and facility-staff authentication APIs.
src/services/authService.ts - API client · Common backend request behavior.
src/lib/apiClient.ts - Socket state · Centralized live-update lifecycle and state.
src/contexts/SocketContext.tsx - Socket client
src/lib/socketClient.ts - Notification delivery · In-app notification service and Firebase messaging integration.
src/services/notificationService.ts
External platforms
Backend and push-delivery boundaries outside this repository.
- FastAPI and PostgreSQL · External API and persistent care-data service.
- Firebase Cloud Messaging · External browser push delivery.
src/lib/firebaseClient.ts
Build and delivery
- CI workflow
.github/workflows/ci.yml - Security workflow
.github/workflows/security.yml
Connections 27
- HTML entry → React bootstrap: loads
- React bootstrap → App and routes: mounts
- App and routes → Public and auth pages: routes public users
- App and routes → Protected route: guards app routes
- Protected route → Authenticated layout: admits authenticated users
- Authenticated layout → Mother care UI: hosts
- Authenticated layout → CHW care UI: hosts
- Authenticated layout → Nurse care UI: hosts
- Authenticated layout → Facility operations UI: hosts
- Public and auth pages → Onboarding dialogs: continues registration
- Public and auth pages → Auth state: updates identity
- Auth state → Authentication services: authenticates through
- Authentication services → API client: uses
- Mother care UI → Care domain services: care actions
- CHW care UI → Care domain services: care actions
- Nurse care UI → Care domain services: care actions
- Facility operations UI → Care domain services: care actions
- Care domain services → API client: uses
- API client → FastAPI and PostgreSQL: HTTP API
- Socket state → Socket client: manages
- Socket client → FastAPI and PostgreSQL: live updates
- Socket state → Mother care UI: alerts and updates
- Socket state → CHW care UI: alerts and updates
- Socket state → Nurse care UI: alerts and updates
- Socket state → Facility operations UI: alerts and updates
- Notification delivery → Firebase Cloud Messaging: push delivery
- Firebase Cloud Messaging → Push service worker: invokes