Skip to content

Latest commit

 

History

History
286 lines (172 loc) · 10.7 KB

File metadata and controls

286 lines (172 loc) · 10.7 KB

🚨 DETAILED MISSING FEATURES & INTEGRATION PLAN (as of Feb 2026)

Below is a step-by-step, plain-language checklist of every missing or incomplete feature, API, and socket integration in the LifeLine codebase. This is written for maximum clarity—no technical jargon, just what’s missing and what needs to be done.


🟥 Backend: What’s Missing

  1. NGO Resource Management
  • There are no backend APIs for NGOs to add, update, or remove resources like blood banks, beds, or volunteers.
  • No way for NGOs to see or manage their resources in the backend.
  1. NGO Dashboard Data
  • The backend does not collect or send summary stats for NGOs (like number of cases, resources, or payments).
  1. NGO Payment Logic
  • Payment endpoints exist, but there is no logic for actually processing payouts, updating payment status, or letting admins review payments.
  1. Helper History
  • Helpers cannot get a list of all their past cases or services from the backend.
  1. Medical Profile CRUD
  • The backend has some medical data logic, but full create, read, update, and delete (CRUD) for user medical info is not complete or robust.
  • Medical info is not always included in SOS/emergency flows.
  1. Admin Endpoints
  • There are no backend APIs for admins to approve or reject NGOs, helpers, or manage system data.
  1. Socket Events
  • Not all real-time events are implemented. For example, NGOs and helpers do not get live updates about resources, payments, or admin actions.

🟧 Frontend: What’s Missing

  1. NGO Registration Screen
  • There is no screen for NGOs to sign up, upload documents, or select their service type.
  1. NGO Dashboard
  • NGOs cannot see a dashboard with their stats, resources, or payments.
  1. NGO Profile Page
  • There is no detailed page showing NGO info, status, and contact details for users/helpers.
  1. NGO Payment UI
  • NGOs cannot view their payment history or start a payment from the frontend.
  1. NGO Resource Management UI
  • NGOs cannot add, edit, or remove resources (like blood, beds, volunteers) from the frontend.
  1. Helper Payment/Earnings Screen
  • Helpers cannot see their earnings, payment status, or transaction history.
  1. Helper History Screen
  • Helpers cannot see a list of their past cases or services.
  1. Medical Profile CRUD UI
  • Users cannot fully add, edit, or delete their medical info in the app.
  1. SOS AI Triage UI
  • The SOS AI screen is present, but does not have full voice-to-text, text-to-voice, or backend integration.
  1. Nearby NGOs
  • The Nearby screen shows NGOs, but you cannot tap to see full NGO profiles or request help from an NGO.
  1. Admin Management UIs
  • There are no screens for admins to approve/reject NGOs or helpers, or manage system data.
  1. Profile Completion UI
  • There is no progress bar or checklist showing users/helpers/NGOs what steps are missing in their profile.
  1. Socket Integration
  • Many screens do not use real-time updates (for example, payment status, resource changes, or admin notifications).
  1. Error Handling & Loading States
  • Some screens do not show errors or loading spinners when waiting for data or when something goes wrong.

🟦 API & Socket Integration: What’s Not Connected

  1. NGO API
  • The frontend does not call all the backend NGO APIs (registration, dashboard, payments, resource management).
  1. Helper Payment API
  • The frontend does not use the helper payment endpoints.
  1. Medical Profile API
  • The frontend does not fully use the backend medical info endpoints.
  1. Socket Events
  • Real-time updates for NGOs, helpers, and users are not fully connected in the frontend (for example, payment status, resource changes, admin actions).
  1. Testing
  • There are no end-to-end tests for these new flows.

✅ What To Do Next (Step-by-Step)

  1. Backend:
  • Build APIs for NGO resource management, dashboard stats, and payment logic.
  • Add endpoints for helper history, admin approvals, and robust medical CRUD.
  • Implement all missing socket events for real-time updates.
  1. Frontend:
  • Create screens for NGO registration, dashboard, profile, payments, and resource management.
  • Add helper earnings/history screens, medical CRUD, and admin management UIs.
  • Add profile completion progress bars/checklists.
  • Integrate all missing APIs and sockets.
  • Improve error handling and loading states everywhere.
  1. Testing:
  • Write end-to-end tests for all new features and flows.
  1. Documentation:
  • Update API docs and UI guides for all new features.

This checklist is your roadmap. Work through each item to make LifeLine complete, reliable, and user-friendly for everyone.

🛠️ LifeLine - Technical Implementation Plan (Frontend-Backend Sync & Real-time)

This plan outlines the specific steps needed to bridge the gap between the existing frontend UI and the missing backend features, with a focus on real-time Socket.IO integration, external AI integrations, and missing application screens.


🏗️ 1. Backend API Extensions (Gaps)

1.1 Helper Dashboard Service

The current Helper Dashboard UI is hardcoded. We need a dedicated metrics endpoint.

  • Model Update: Add Earning and ServiceLog schemas or aggregate from Emergency model.
  • Controller: HelperController.getDashboardMetrics(helperId)
    • Endpoint: GET /api/helpers/v1/:id/dashboard

    • Payload:

      {
        "today": { "onlineTime": "3h 15m", "callsAttended": 5 },
        "earnings": { "total": 45200, "pending": 3400, "weeklyGrowth": "+12%" },
        "stats": { "casesSolved": 124, "activeCases": 1 },
        "recentActivity": [
          { "time": "10:30 AM", "title": "Cardiac Arrest #4092", "status": "Completed", "payout": 500 }
        ]
      }

1.2 NGO Registration & Community Support

We need to support full NGO registration alongside fetching nearby organizations.

  • New Module: NGO

    • Schema: Name, Location, ServiceType, Contact, Distance, RegistrationStatus, Documents
    • Controller: NGOController.getNearby(lat, lng, radius), NGOAuth.register()
    • Endpoint: GET /api/ngo/v1/nearby, POST /api/ngo/v1/register
  • Frontend Signup Integration: Allow users to choose "NGO" on the signup page and complete an NGO-specific registration flow.

1.3 Medical Data Management (Full CRUD)

The UserController currently only handles a reference to medicalId.

  • Implementation: Implement full CRUD in MedicalController.
  • Integration: Ensure EmergencyService.triggerSOS fetches the latest medical data to include in the SOS alert broadcast to helpers.

🤖 2. Sarvam AI Voice Triage Integration (SOS Activation)

2.1 SOS Activate AI Screen

  • User Flow: When the user clicks the global SOS button, SOS mode activates immediately. They are redirected to a dedicated "SOS Activate AI Screen".
  • Sarvam AI Integration: Utilize Sarvam API for real-time, regional language voice interactions.
    • Speech-to-Text (STT): Transcribe the user's spoken emergency details, parsing language, nuances, and urgency.
    • Text-to-Speech (TTS): Allow the AI Triage agent to respond back with clarifying questions or reassuring voice instructions in natural audio.
  • Implementation:
    • Setup React Native / Expo audio capture.
    • Stream audio to backend/Sarvam AI.
    • Build UI with audio waveforms / glowing mic indications to provide interaction feedback.

📱 3. Frontend Wiring (UI to State) & Missing Pages

3.1 Helper Dashboard Connectivity

  • Replace hardcoded values in app/Helper/Dashboard.tsx with selectors from helperSlice or a new dashboardSlice.
  • Add useEffect to fetch dashboard data on mount.
  • Wire StatusToggle to the updateAvailability thunk.

3.2 Nearby Features Connectivity

  • Update app/User/Nearby.tsx to use useSelector for the helper list.
  • Fetch real NGOs from the new GET /api/ngo/v1/nearby endpoint.

3.3 Map Screen & Helper Tracking

  • Remove Mock Data: Update app/(global)/Map.tsx to read helperLocation and userLocation from emergencySlice.
  • Socket Subscription: Use socketService.onUserLocationUpdate to move markers in real-time.
  • Auto-Routing: Ensure the map re-calculates the route geometry only when the distance moved exceeds a threshold (e.g., 50m) to save performance.

3.4 Missing Frontend Pages (User, Helper, NGO)

The overall flow has gaps that need to be built:

  • User Screens:
    • User/SOSActivate (The Sarvam AI Voice Triage interact screen).
    • User/MedicalProfile (Dedicated full CRUD forms for updating medical conditions/history).
  • Helper Screens:
    • Helper/Registration (Helper specific onboarding and verified documents upload).
    • Helper/History (Record of past received and solved emergencies).
  • NGO Screens:
    • Signup Add NGO type branching in main registration.
    • NGO/Dashboard (Resource overview, incoming nearby cases).
    • NGO/ResourceMgr (Management flow for blood banks, beds, volunteers).

📋 4. Implementation Checklist (Step-by-Step)

Phase A: Backend Infrastructure (Immediate)

  • Implement Helper.getDashboard logic.
  • Implement NGO.getNearby and NGOAuth.register controllers.
  • Add Message schema and persistence in emergency:sendMessage.
  • Verify triage.handler.mjs is correctly linked to AI service.

Phase B: External Service Integration Layer

  • Add TRIAGE emitters to socketService.ts.
  • Add listeners for emergency:joined, emergency:message, location:userLocationUpdate.
  • Create socketMiddleware in Redux to handle incoming socket events.
  • Sarvam AI APIs: Integrate Sarvam STT and TTS in the triage message-processing loop.

Phase C: Dashboard, Nearby & Missing Pages Construction

  • Implement user flow branching: NGO vs Helper vs User Registration.
  • Build the User/SOSActivate screen and plug in Sarvam audio streams.
  • Build missing pages: Helper/Registration, Helper/History, User/MedicalProfile, NGO/Dashboard.
  • Connect HelperDashboard to helperSlice metrics.
  • Replace Nearby.tsx static list with nearbyHelpers from emergencySlice.
  • Implement the "Incoming Emergency" alert modal for helpers.

Phase D: Testing & Validation

  • End-to-End SOS: Trigger SOS (User) -> Receive Alert (Helper) -> Accept (Helper) -> Track Map (Both).
  • AI Triage with Sarvam: Click SOS -> SOS Activate Screen -> Speak problem (STT) -> Receive instruction (TTS) -> Broadcast details.
  • Offline Resilience: Test socket reconnection logic on network switch.

Note: Priority should be given to the Emergency Alerting Flow as it is the core "Life-Saving" feature of the app.