Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
64 changes: 59 additions & 5 deletions homeflow/CLAUDE.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,23 @@
# AI Coding Instructions
# AI Coding Instructions for HomeFlow

## Stack
## Project Context

React Native, Expo 54, TypeScript, Expo Router, Formik + Yup
**Project:** HomeFlow - BPH Patient Digital Health Study
**Course:** CS342 – Building for Digital Health
**Team:** Stream Team (Team 3)
**Platform:** iOS-first (React Native / Expo), cross-platform where feasible

**Purpose:** Enable passive, longitudinal measurement of voiding patterns, activity, and sleep in the home environment for BPH patients before and after bladder outlet surgery.

## Tech Stack

- React Native + Expo 54, TypeScript, Expo Router
- Spezi Vibe framework
- Apple HealthKit + Apple Watch integration
- Apple ResearchKit (consent/enrollment)
- Throne Uroflow API
- Formik + Yup (forms/validation)
- Cloud backend (PI-managed; e.g., GCP / Medplum / Firebase)

## Commands

Expand All @@ -11,6 +26,22 @@ npx expo start # Start dev server (press i for iOS, a for Android)
npm test # Run tests
```

## Core Data Types

### Throne Uroflow Data
- Void timestamp, voided volume
- Maximum flow rate (Qmax), average flow rate (Qavg)
- Flow curve shape, voiding frequency
- Nocturia events, patient annotations (straining, urgency)

### Apple HealthKit / Watch Data
- Step count, active minutes, sedentary time
- Sleep duration and stages
- Heart rate and vitals (when available)

### Surveys
- IPSS (International Prostate Symptom Score) - collected longitudinally

## Provider Hierarchy

Order matters - don't rearrange:
Expand All @@ -22,10 +53,21 @@ StandardProvider → SchedulerProvider → AccountProvider → App

1. **Always use Standard** - Access data via `useStandard()`, never import backends directly
2. **AccountService = auth only** - Login, register, logout, profile
3. **BackendService = data only** - Tasks, outcomes, questionnaires
3. **BackendService = data only** - Tasks, outcomes, questionnaires, uroflow, HealthKit
4. **Cancellation tokens** - Every async effect needs `let cancelled = false`
5. **Memoize context values** - Always `useMemo` for provider values
6. **Declarative auth guards** - Use `<Redirect href="..." />`, not `router.replace()`
7. **Privacy-first** - De-identify data before upload; no unnecessary PHI
8. **Research-only** - No real-time clinical alerts or treatment recommendations
9. **Adhere to PRD** - All AI-generated code must strictly follow `docs/PRD.md`

## Key Flows

1. **Enrollment & Consent** - ResearchKit-based eligibility screening and informed consent
2. **Permissions** - HealthKit access, Watch data, Throne device access
3. **Initial Data Intake** - Demographics from HealthKit + chatbot-assisted history + baseline IPSS
4. **Daily Passive Collection** - Uroflow, activity, sleep data synced ~once per day
5. **Periodic Surveys** - IPSS prompts at defined intervals

## Key Files

Expand All @@ -34,6 +76,7 @@ StandardProvider → SchedulerProvider → AccountProvider → App
| `lib/services/standard-context.tsx` | Standard pattern - provides backend & auth |
| `app/_layout.tsx` | Root layout with providers and auth guards |
| `app/(tabs)/_layout.tsx` | Tab navigation |
| `docs/PRD.md` | Product requirements - source of truth |

## Don't

Expand All @@ -43,6 +86,17 @@ StandardProvider → SchedulerProvider → AccountProvider → App
- Use `router.replace()` for auth guards
- Forget cleanup functions in useEffect
- Skip cancellation tokens in async effects
- Build real-time clinical decision support
- Store unnecessary PHI
- Deviate from PRD requirements without explicit approval

## Constraints & Assumptions

- This is a **research prototype** for CS342 - demo-safe implementations acceptable
- Backend may be simulated or partially stubbed
- Data collected is **not used for clinical care**
- During demos, Throne uroflow data may be simulated if hardware unavailable
- iOS HealthKit limitations acknowledged (e.g., delayed syncs)

## Development Agents

Expand All @@ -69,4 +123,4 @@ Claude Code agents for common tasks. Invoke with `/agent-name`.
| data-model | `/data-model` | Design health data models and FHIR structures |
| ux-planner | `/ux-planner` | Design user flows and engagement strategies |

Agent definitions are in `.claude/agents/`.
Agent definitions are in `.claude/commands/`.
79 changes: 79 additions & 0 deletions homeflow/app/(onboarding)/_layout.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
/**
* Onboarding Layout
*
* Stack navigator for onboarding flow with smooth transitions.
* Disables back gesture to prevent users from skipping steps.
*/

import React from 'react';
import { Stack } from 'expo-router';
import { useColorScheme } from 'react-native';
import { Colors } from '@/constants/theme';

export default function OnboardingLayout() {
const colorScheme = useColorScheme();
const colors = Colors[colorScheme ?? 'light'];

return (
<Stack
screenOptions={{
headerShown: false,
gestureEnabled: false, // Prevent back gesture
animation: 'fade_from_bottom',
contentStyle: {
backgroundColor: colors.background,
},
}}
>
<Stack.Screen
name="index"
options={{
animation: 'none',
}}
/>
<Stack.Screen
name="welcome"
options={{
animation: 'fade',
}}
/>
<Stack.Screen
name="chat"
options={{
animation: 'slide_from_right',
}}
/>
<Stack.Screen
name="ineligible"
options={{
animation: 'fade',
}}
/>
<Stack.Screen
name="consent"
options={{
animation: 'slide_from_right',
}}
/>
<Stack.Screen
name="permissions"
options={{
animation: 'slide_from_right',
}}
/>
<Stack.Screen
name="baseline-survey"
options={{
animation: 'slide_from_bottom',
presentation: 'formSheet',
}}
/>
<Stack.Screen
name="complete"
options={{
animation: 'fade',
}}
/>
</Stack>
);
}
Loading
Loading