# charanachanta2/lifelinkai architecture

> Architecture diagram of the GitHub repository charanachanta2/lifelinkai, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-12). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/charanachanta2/lifelinkai
- Repository: https://github.com/charanachanta2/lifelinkai

## Overview

LifeLink is an Expo mobile app for civilians and public-service agencies. Its visible crash-alert flow runs from the home screen through sensor monitoring and crash detection to an emergency callback and emergency screen. Other major product areas in the tree include nearby emergency discovery, blood-bank services, health records, analytics, agency incident handling, and account/profile management. Several of those screens were not sampled, so their internal calls and backend relationships are not inferred here.

Main entry points: [`context/AuthContext.tsx`](https://github.com/charanachanta2/lifelinkai/blob/main/context/AuthContext.tsx) (Session and authentication), [`app/(tabs)/index.tsx`](https://github.com/charanachanta2/lifelinkai/blob/main/app/(tabs)/index.tsx) (Home and monitoring), [`utils/AIEngine.ts`](https://github.com/charanachanta2/lifelinkai/blob/main/utils/AIEngine.ts) (Crash processing), [`app/emergency.tsx`](https://github.com/charanachanta2/lifelinkai/blob/main/app/emergency.tsx) (Emergency response)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_crash["Crash alerts"]
  node_home["Home and monitoring<br/>[index.tsx]"]
  node_sensors["Sensor manager<br/>[SensorManager.ts]"]
  node_ai["Crash processing<br/>[AIEngine.ts]"]
  node_detection["Crash detection<br/>[CrashDetection.ts]"]
  node_detector["Crash detector<br/>[CrashDetector.ts]"]
  node_model["Crash model<br/>[CrashModel.ts]"]
  node_emergency_mgr["Emergency callback"]
end

subgraph group_civilian["Civilian services"]
  node_emergency_screen["Emergency response<br/>[emergency.tsx]"]
  node_countdown["Emergency countdown"]
  node_discovery["Find emergency help<br/>[find-emergency.tsx]"]
  node_blood["Blood-bank services<br/>[blood-bank.tsx]"]
  node_health["Health records<br/>[index.tsx]"]
  node_activity_map["Activity map<br/>[map-activity.tsx]"]
  node_analytics["Analytics<br/>[analytics.tsx]"]
end

subgraph group_agency["Agency operations"]
  node_agency_home["Agency home"]
  node_agency_map["Agency map"]
  node_reports["Incident reports"]
  node_agency_config["Agency presentation<br/>[agency.ts]"]
end

subgraph group_identity["Identity and account"]
  node_auth["Session and authentication<br/>[AuthContext.tsx]"]
  node_profile["Profile management<br/>[profile.tsx]"]
  node_push["Push registration"]
end

node_user(("App user"))
node_backend[("LifeLink backend")]

node_user -->|"uses"| node_home
node_home -->|"starts sensors"| node_sensors
node_home -->|"loads model"| node_model
node_home -->|"registers callback"| node_emergency_mgr
node_sensors -->|"sends readings"| node_ai
node_ai -->|"checks crash"| node_detection
node_detection -->|"uses detector"| node_detector
node_ai -->|"triggers alert"| node_emergency_mgr
node_emergency_mgr -->|"fires callback"| node_emergency_screen
node_emergency_screen -->|"renders countdown"| node_countdown
node_user -->|"finds nearby help"| node_discovery
node_user -->|"uses blood bank"| node_blood
node_user -->|"views activity"| node_activity_map
node_user -->|"views analytics"| node_analytics
node_user -->|"uses agency tools"| node_agency_home
node_agency_home -->|"gets role theme"| node_agency_config
node_user -->|"views agency map"| node_agency_map
node_user -->|"handles incidents"| node_reports
node_reports -->|"fetches incidents"| node_backend
node_user -->|"signs in"| node_auth
node_auth -->|"registers push"| node_push
node_auth -->|"auth requests"| node_backend
node_user -->|"manages account"| node_profile
node_profile -->|"reads session"| node_auth
node_profile -->|"updates account"| node_backend
node_emergency_screen -.->|"uses session"| node_auth
node_blood -.->|"uses session"| node_auth
node_discovery -.->|"uses session"| node_auth
node_activity_map -.->|"uses session"| node_auth

click node_home "https://github.com/charanachanta2/lifelinkai/blob/main/app/(tabs)/index.tsx"
click node_sensors "https://github.com/charanachanta2/lifelinkai/blob/main/utils/SensorManager.ts"
click node_ai "https://github.com/charanachanta2/lifelinkai/blob/main/utils/AIEngine.ts"
click node_detection "https://github.com/charanachanta2/lifelinkai/blob/main/utils/CrashDetection.ts"
click node_detector "https://github.com/charanachanta2/lifelinkai/blob/main/utils/CrashDetector.ts"
click node_model "https://github.com/charanachanta2/lifelinkai/blob/main/utils/CrashModel.ts"
click node_emergency_mgr "https://github.com/charanachanta2/lifelinkai/blob/main/utils/EmergencyManager.ts"
click node_emergency_screen "https://github.com/charanachanta2/lifelinkai/blob/main/app/emergency.tsx"
click node_countdown "https://github.com/charanachanta2/lifelinkai/blob/main/components/CountdownCircle.tsx"
click node_discovery "https://github.com/charanachanta2/lifelinkai/blob/main/app/(tabs)/find-emergency.tsx"
click node_blood "https://github.com/charanachanta2/lifelinkai/blob/main/app/(tabs)/blood-bank.tsx"
click node_health "https://github.com/charanachanta2/lifelinkai/blob/main/app/(tabs)/index.tsx"
click node_activity_map "https://github.com/charanachanta2/lifelinkai/blob/main/app/(tabs)/map-activity.tsx"
click node_analytics "https://github.com/charanachanta2/lifelinkai/blob/main/app/(tabs)/analytics.tsx"
click node_agency_home "https://github.com/charanachanta2/lifelinkai/blob/main/components/AgencyHomeScreen.tsx"
click node_agency_map "https://github.com/charanachanta2/lifelinkai/blob/main/components/AgencyMapScreen.tsx"
click node_reports "https://github.com/charanachanta2/lifelinkai/blob/main/components/AgencyReportsScreen.tsx"
click node_agency_config "https://github.com/charanachanta2/lifelinkai/blob/main/constants/agency.ts"
click node_auth "https://github.com/charanachanta2/lifelinkai/blob/main/context/AuthContext.tsx"
click node_profile "https://github.com/charanachanta2/lifelinkai/blob/main/app/profile.tsx"
click node_push "https://github.com/charanachanta2/lifelinkai/blob/main/utils/pushNotifications.ts"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_home,node_sensors,node_ai,node_detection,node_detector,node_model,node_emergency_mgr,node_user toneBlue
class node_emergency_screen,node_countdown,node_discovery,node_blood,node_health,node_activity_map,node_analytics,node_backend toneAmber
class node_agency_home,node_agency_map,node_reports,node_agency_config toneMint
class node_auth,node_profile,node_push toneRose
```

## Components

### Crash alerts

- [Home and monitoring](https://github.com/charanachanta2/lifelinkai/blob/main/app/(tabs)/index.tsx): `app/(tabs)/index.tsx`
- [Sensor manager](https://github.com/charanachanta2/lifelinkai/blob/main/utils/SensorManager.ts): `utils/SensorManager.ts`
- [Crash processing](https://github.com/charanachanta2/lifelinkai/blob/main/utils/AIEngine.ts): `utils/AIEngine.ts`
- [Crash detection](https://github.com/charanachanta2/lifelinkai/blob/main/utils/CrashDetection.ts): `utils/CrashDetection.ts`
- [Crash detector](https://github.com/charanachanta2/lifelinkai/blob/main/utils/CrashDetector.ts): `utils/CrashDetector.ts`
- [Crash model](https://github.com/charanachanta2/lifelinkai/blob/main/utils/CrashModel.ts): `utils/CrashModel.ts`
- [Emergency callback](https://github.com/charanachanta2/lifelinkai/blob/main/utils/EmergencyManager.ts): `utils/EmergencyManager.ts`

### Civilian services

- [Emergency response](https://github.com/charanachanta2/lifelinkai/blob/main/app/emergency.tsx): `app/emergency.tsx`
- [Emergency countdown](https://github.com/charanachanta2/lifelinkai/blob/main/components/CountdownCircle.tsx): `components/CountdownCircle.tsx`
- [Find emergency help](https://github.com/charanachanta2/lifelinkai/blob/main/app/(tabs)/find-emergency.tsx): `app/(tabs)/find-emergency.tsx`
- [Blood-bank services](https://github.com/charanachanta2/lifelinkai/blob/main/app/(tabs)/blood-bank.tsx): `app/(tabs)/blood-bank.tsx`
- [Health records](https://github.com/charanachanta2/lifelinkai/blob/main/app/(tabs)/index.tsx): `app/(tabs)/index.tsx`
- [Activity map](https://github.com/charanachanta2/lifelinkai/blob/main/app/(tabs)/map-activity.tsx): `app/(tabs)/map-activity.tsx`
- [Analytics](https://github.com/charanachanta2/lifelinkai/blob/main/app/(tabs)/analytics.tsx): `app/(tabs)/analytics.tsx`

### Agency operations

- [Agency home](https://github.com/charanachanta2/lifelinkai/blob/main/components/AgencyHomeScreen.tsx): `components/AgencyHomeScreen.tsx`
- [Agency map](https://github.com/charanachanta2/lifelinkai/blob/main/components/AgencyMapScreen.tsx): `components/AgencyMapScreen.tsx`
- [Incident reports](https://github.com/charanachanta2/lifelinkai/blob/main/components/AgencyReportsScreen.tsx): `components/AgencyReportsScreen.tsx`
- [Agency presentation](https://github.com/charanachanta2/lifelinkai/blob/main/constants/agency.ts): `constants/agency.ts`

### Identity and account

- [Session and authentication](https://github.com/charanachanta2/lifelinkai/blob/main/context/AuthContext.tsx): `context/AuthContext.tsx`
- [Profile management](https://github.com/charanachanta2/lifelinkai/blob/main/app/profile.tsx): `app/profile.tsx`
- [Push registration](https://github.com/charanachanta2/lifelinkai/blob/main/utils/pushNotifications.ts): `utils/pushNotifications.ts`

### Other components

- **App user**
- **LifeLink backend**

## Connections

- App user → Home and monitoring: uses
- Home and monitoring → Sensor manager: starts sensors (evidence: `app/(tabs)/index.tsx`)
- Home and monitoring → Crash model: loads model (evidence: `app/(tabs)/index.tsx`)
- Home and monitoring → Emergency callback: registers callback (evidence: `app/(tabs)/index.tsx`)
- Sensor manager → Crash processing: sends readings (evidence: `utils/SensorManager.ts`)
- Crash processing → Crash detection: checks crash (evidence: `utils/AIEngine.ts`)
- Crash detection → Crash detector: uses detector (evidence: `utils/CrashDetection.ts`)
- Crash processing → Emergency callback: triggers alert (evidence: `utils/AIEngine.ts`)
- Emergency callback → Emergency response: fires callback (evidence: `app/emergency.tsx`)
- Emergency response → Emergency countdown: renders countdown (evidence: `app/emergency.tsx`)
- App user → Find emergency help: finds nearby help
- App user → Blood-bank services: uses blood bank
- App user → Activity map: views activity
- App user → Analytics: views analytics
- App user → Agency home: uses agency tools
- Agency home → Agency presentation: gets role theme (evidence: `components/AgencyHomeScreen.tsx`)
- App user → Agency map: views agency map
- App user → Incident reports: handles incidents
- Incident reports → LifeLink backend: fetches incidents (evidence: `components/AgencyReportsScreen.tsx`)
- App user → Session and authentication: signs in
- Session and authentication → Push registration: registers push (evidence: `context/AuthContext.tsx`)
- Session and authentication → LifeLink backend: auth requests (evidence: `context/AuthContext.tsx`)
- App user → Profile management: manages account
- Profile management → Session and authentication: reads session (evidence: `app/profile.tsx`)
- Profile management → LifeLink backend: updates account (evidence: `app/profile.tsx`)
- Emergency response → Session and authentication: uses session (evidence: `app/emergency.tsx`)
- Blood-bank services → Session and authentication: uses session (evidence: `app/(tabs)/blood-bank.tsx`)
- Find emergency help → Session and authentication: uses session (evidence: `app/(tabs)/find-emergency.tsx`)
- Activity map → Session and authentication: uses session (evidence: `app/(tabs)/map-activity.tsx`)
