# cvanshu-dev/resilio architecture

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

- Interactive diagram: https://gitdiagram.com/cvanshu-dev/resilio
- Repository: https://github.com/cvanshu-dev/resilio

## Overview

RESILIO is an Expo app for personnel wellness and officer oversight, with a separate ML inference service. Its principal workflow is role-based access to personnel health, check-in and duty inputs, followed by baseline-aware risk and outcome analysis, interpretation and recommendations; officers have separate monitoring and support views. The sampled intelligence orchestrator explicitly wires the analysis stages. Route internals and health-data acquisition wiring were not sampled, so those connections are left out rather than inferred.

Main entry points: [`src/lib/intelligenceEngine.ts`](https://github.com/cvanshu-dev/resilio/blob/main/src/lib/intelligenceEngine.ts) (Analysis orchestrator), [`src/app/index.tsx`](https://github.com/cvanshu-dev/resilio/blob/main/src/app/index.tsx) (Role dispatch), [`src/app/(public)/login.tsx`](https://github.com/cvanshu-dev/resilio/blob/main/src/app/(public)/login.tsx) (Public access), [`src/providers/AuthProvider.tsx`](https://github.com/cvanshu-dev/resilio/blob/main/src/providers/AuthProvider.tsx) (Auth and profile)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_app["Role-based app"]
  node_entry["Role dispatch<br/>[index.tsx]"]
  node_public["Public access<br/>[login.tsx]"]
  node_personnel["Personnel area<br/>[index.tsx]"]
  node_officerarea["Officer area<br/>[index.tsx]"]
  node_alerts["Officer alerts<br/>[alerts.tsx]"]
  node_analytics["Officer analytics<br/>[analytics.tsx]"]
  node_staff["Personnel oversight<br/>[personnel-list.tsx]"]
end

subgraph group_inputs["Wellness inputs"]
  node_checkin["Wellness check-in<br/>[checkin.tsx]"]
  node_duty["Duty tracking<br/>[duty.tsx]"]
  node_healthview["Health view<br/>[health.tsx]"]
  node_support["Support requests<br/>[support.tsx]"]
end

subgraph group_analysis["Health intelligence"]
  node_baseline["Personal baseline<br/>[baselineEngine.ts]"]
  node_features["Feature engineering<br/>[featureEngine.ts]"]
  node_risk["Risk assessment<br/>[riskEngine.ts]"]
  node_outcomes["Outcome inference<br/>[outcomeEngine.ts]"]
  node_interpretation["Interpretation"]
  node_recommendations["Recommendations"]
  node_intelligence["Analysis orchestrator"]
  node_mlfeatures["ML feature payload<br/>[mlFeatureEngine.ts]"]
  node_trends["Trend analysis<br/>[trendEngine.ts]"]
end

subgraph group_services["Data and inference"]
  node_auth["Auth and profile<br/>[AuthProvider.tsx]"]
  node_supabase["Supabase client<br/>[supabase.ts]"]
  node_healthkit["HealthKit adapter<br/>[healthkit.ts]"]
  node_mlclient["ML client<br/>[mlClient.ts]"]
end

node_person(("Personnel user"))
node_officer(("Officer user"))
node_supabase_service[("Supabase")]
node_mlservice["ML inference API<br/>[app.py]"]

node_person -->|"opens app"| node_public
node_officer -->|"opens app"| node_public
node_public -->|"continues"| node_entry
node_entry -->|"reads session"| node_auth
node_entry -->|"routes personnel"| node_personnel
node_entry -->|"routes officers"| node_officerarea
node_auth -->|"queries profile"| node_supabase
node_supabase -->|"reads auth and profiles"| node_supabase_service
node_intelligence -->|"calculates baseline"| node_baseline
node_intelligence -->|"builds features"| node_features
node_intelligence -->|"builds ML payload"| node_mlfeatures
node_intelligence -->|"calculates risk"| node_risk
node_intelligence -->|"infers outcomes"| node_outcomes
node_intelligence -->|"builds interpretation"| node_interpretation
node_intelligence -->|"generates advice"| node_recommendations
node_intelligence -->|"requests prediction"| node_mlclient
node_mlclient -.->|"sends features"| node_mlservice
node_healthview -.->|"uses health data"| node_healthkit

click node_entry "https://github.com/cvanshu-dev/resilio/blob/main/src/app/index.tsx"
click node_public "https://github.com/cvanshu-dev/resilio/blob/main/src/app/(public)/login.tsx"
click node_personnel "https://github.com/cvanshu-dev/resilio/blob/main/src/app/(personnel)/index.tsx"
click node_officerarea "https://github.com/cvanshu-dev/resilio/blob/main/src/app/(officer)/index.tsx"
click node_checkin "https://github.com/cvanshu-dev/resilio/blob/main/src/app/(personnel)/checkin.tsx"
click node_duty "https://github.com/cvanshu-dev/resilio/blob/main/src/app/(personnel)/duty.tsx"
click node_healthview "https://github.com/cvanshu-dev/resilio/blob/main/src/app/(personnel)/health.tsx"
click node_support "https://github.com/cvanshu-dev/resilio/blob/main/src/app/(personnel)/support.tsx"
click node_alerts "https://github.com/cvanshu-dev/resilio/blob/main/src/app/(officer)/alerts.tsx"
click node_analytics "https://github.com/cvanshu-dev/resilio/blob/main/src/app/(officer)/analytics.tsx"
click node_staff "https://github.com/cvanshu-dev/resilio/blob/main/src/app/(officer)/personnel-list.tsx"
click node_auth "https://github.com/cvanshu-dev/resilio/blob/main/src/providers/AuthProvider.tsx"
click node_supabase "https://github.com/cvanshu-dev/resilio/blob/main/src/lib/supabase.ts"
click node_healthkit "https://github.com/cvanshu-dev/resilio/blob/main/src/lib/healthkit.ts"
click node_baseline "https://github.com/cvanshu-dev/resilio/blob/main/src/lib/baselineEngine.ts"
click node_features "https://github.com/cvanshu-dev/resilio/blob/main/src/lib/featureEngine.ts"
click node_risk "https://github.com/cvanshu-dev/resilio/blob/main/src/lib/riskEngine.ts"
click node_outcomes "https://github.com/cvanshu-dev/resilio/blob/main/src/lib/outcomeEngine.ts"
click node_interpretation "https://github.com/cvanshu-dev/resilio/blob/main/src/lib/interpretationEngine.ts"
click node_recommendations "https://github.com/cvanshu-dev/resilio/blob/main/src/lib/recommendationEngine.ts"
click node_intelligence "https://github.com/cvanshu-dev/resilio/blob/main/src/lib/intelligenceEngine.ts"
click node_mlfeatures "https://github.com/cvanshu-dev/resilio/blob/main/src/lib/mlFeatureEngine.ts"
click node_mlclient "https://github.com/cvanshu-dev/resilio/blob/main/src/lib/mlClient.ts"
click node_mlservice "https://github.com/cvanshu-dev/resilio/blob/main/ml/app.py"
click node_trends "https://github.com/cvanshu-dev/resilio/blob/main/src/lib/trendEngine.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_entry,node_public,node_personnel,node_officerarea,node_alerts,node_analytics,node_staff,node_person,node_officer toneBlue
class node_checkin,node_duty,node_healthview,node_support,node_supabase_service toneAmber
class node_baseline,node_features,node_risk,node_outcomes,node_interpretation,node_recommendations,node_intelligence,node_mlfeatures,node_trends,node_mlservice toneMint
class node_auth,node_supabase,node_healthkit,node_mlclient toneRose
```

## Components

### Role-based app

- [Role dispatch](https://github.com/cvanshu-dev/resilio/blob/main/src/app/index.tsx): `src/app/index.tsx`
- [Public access](https://github.com/cvanshu-dev/resilio/blob/main/src/app/(public)/login.tsx): `src/app/(public)/login.tsx`
- [Personnel area](https://github.com/cvanshu-dev/resilio/blob/main/src/app/(personnel)/index.tsx): `src/app/(personnel)/index.tsx`
- [Officer area](https://github.com/cvanshu-dev/resilio/blob/main/src/app/(officer)/index.tsx): `src/app/(officer)/index.tsx`
- [Officer alerts](https://github.com/cvanshu-dev/resilio/blob/main/src/app/(officer)/alerts.tsx): `src/app/(officer)/alerts.tsx`
- [Officer analytics](https://github.com/cvanshu-dev/resilio/blob/main/src/app/(officer)/analytics.tsx): `src/app/(officer)/analytics.tsx`
- [Personnel oversight](https://github.com/cvanshu-dev/resilio/blob/main/src/app/(officer)/personnel-list.tsx): `src/app/(officer)/personnel-list.tsx`

### Wellness inputs

- [Wellness check-in](https://github.com/cvanshu-dev/resilio/blob/main/src/app/(personnel)/checkin.tsx): `src/app/(personnel)/checkin.tsx`
- [Duty tracking](https://github.com/cvanshu-dev/resilio/blob/main/src/app/(personnel)/duty.tsx): `src/app/(personnel)/duty.tsx`
- [Health view](https://github.com/cvanshu-dev/resilio/blob/main/src/app/(personnel)/health.tsx): `src/app/(personnel)/health.tsx`
- [Support requests](https://github.com/cvanshu-dev/resilio/blob/main/src/app/(personnel)/support.tsx): `src/app/(personnel)/support.tsx`

### Health intelligence

- [Personal baseline](https://github.com/cvanshu-dev/resilio/blob/main/src/lib/baselineEngine.ts): `src/lib/baselineEngine.ts`
- [Feature engineering](https://github.com/cvanshu-dev/resilio/blob/main/src/lib/featureEngine.ts): `src/lib/featureEngine.ts`
- [Risk assessment](https://github.com/cvanshu-dev/resilio/blob/main/src/lib/riskEngine.ts): `src/lib/riskEngine.ts`
- [Outcome inference](https://github.com/cvanshu-dev/resilio/blob/main/src/lib/outcomeEngine.ts): `src/lib/outcomeEngine.ts`
- [Interpretation](https://github.com/cvanshu-dev/resilio/blob/main/src/lib/interpretationEngine.ts): `src/lib/interpretationEngine.ts`
- [Recommendations](https://github.com/cvanshu-dev/resilio/blob/main/src/lib/recommendationEngine.ts): `src/lib/recommendationEngine.ts`
- [Analysis orchestrator](https://github.com/cvanshu-dev/resilio/blob/main/src/lib/intelligenceEngine.ts): `src/lib/intelligenceEngine.ts`
- [ML feature payload](https://github.com/cvanshu-dev/resilio/blob/main/src/lib/mlFeatureEngine.ts): `src/lib/mlFeatureEngine.ts`
- [Trend analysis](https://github.com/cvanshu-dev/resilio/blob/main/src/lib/trendEngine.ts): `src/lib/trendEngine.ts`

### Data and inference

- [Auth and profile](https://github.com/cvanshu-dev/resilio/blob/main/src/providers/AuthProvider.tsx): `src/providers/AuthProvider.tsx`
- [Supabase client](https://github.com/cvanshu-dev/resilio/blob/main/src/lib/supabase.ts): `src/lib/supabase.ts`
- [HealthKit adapter](https://github.com/cvanshu-dev/resilio/blob/main/src/lib/healthkit.ts): `src/lib/healthkit.ts`
- [ML client](https://github.com/cvanshu-dev/resilio/blob/main/src/lib/mlClient.ts): `src/lib/mlClient.ts`

### Other components

- **Personnel user**
- **Officer user**
- **Supabase**
- [ML inference API](https://github.com/cvanshu-dev/resilio/blob/main/ml/app.py): `ml/app.py`

## Connections

- Personnel user → Public access: opens app
- Officer user → Public access: opens app
- Public access → Role dispatch: continues
- Role dispatch → Auth and profile: reads session
- Role dispatch → Personnel area: routes personnel
- Role dispatch → Officer area: routes officers
- Auth and profile → Supabase client: queries profile
- Supabase client → Supabase: reads auth and profiles
- Analysis orchestrator → Personal baseline: calculates baseline
- Analysis orchestrator → Feature engineering: builds features
- Analysis orchestrator → ML feature payload: builds ML payload
- Analysis orchestrator → Risk assessment: calculates risk
- Analysis orchestrator → Outcome inference: infers outcomes
- Analysis orchestrator → Interpretation: builds interpretation
- Analysis orchestrator → Recommendations: generates advice
- Analysis orchestrator → ML client: requests prediction
- ML client → ML inference API: sends features
- Health view → HealthKit adapter: uses health data
