# Project export: 4sight

This document was generated by HackStack to give an AI agent context about a hackathon project. Sections are labeled with their provenance; content marked as truncated was cut to keep this document small.

## Project metadata

- Hackathon: TreeHacks 2026
- Tagline: AI-powered biometric and visual monitoring that predicts when you’re prone to bad decisions. With autonomously triggered interventions, 4sight helps you make better decisions for a better you.
- Devpost: https://devpost.com/software/4sight-neoslb
- GitHub: https://github.com/kl527/4sight
- Video: https://player.vimeo.com/video/1165159968?byline=0&portrait=0&title=0#t=
- Result: winner ([Cloudflare] Best Use of Cloudflare Developer Platform (1st Place - $250K Cloudflare credits + Cloudflare swag bag for each team member. 2nd Place - $100k Cloudflare credits))
- Team: 4 GitHub contributor(s) — Ben Juntilla (41 commits), Claude Opus 4.6 (36 commits), kl527 (26 commits), mangia782 (3 commits)

## Devpost submission (written by the team)

### Inspiration

We’re surrounded by tools that track our health, but none that meaningfully protect our decision-making or help us make decisions. Research shows that stress, health, and our environment significantly alter how we evaluate ideas, often leading to impulsive or suboptimal choices (Starcke & Brand, 2012). If our physiology influences decisions so much, we wondered: What if wearables could predict when you’re vulnerable to making bad decisions and intervene before you act? 4sight was built around that idea. Not just tracking health, but a real-time decision-support system that combines internal biometric signals with external environmental context.

### What it does

4sight is an autonomous decision-support system that predicts when you’re prone to making bad decisions based on biometric and contextual data. Drawing on findings that stress and physiological load directly impact decision-making processes, 4sight continuously monitors biosignals such as heart rate and heart rate variability (HRV), motion and exertion metrics, sleep-related indicators, and cognitive and physiological stress signals. In addition, Meta smart glasses provide lightweight environmental context such as visual surroundings and situational cues that help interpret biometric spikes more intelligently. This allows the system to distinguish between healthy exertion and stressful overload, or between calm focus and cognitive fatigue in overstimulating settings. These signals are used to generate five domain-specific risk scores of stress, sleep, health, cognitive exhaustion, and physical exertion. A weighted aggregate produces a general decision-risk score, identifying windows of time where impaired judgment is more likely. When risk crosses a threshold, 4sight autonomously intervenes through various channels: Activating Screen Time APIs to curb doomscrolling during stress spikes Sending nudges via iMessage using Poke AI, which can use MCPs to trigger real-world interventions, like ordering from Amazon Triggering automated actions such as Amazon ordering stress-mitigation products such as magnesium supplements to aid in sleep quality Instead of passively reporting metrics, 4sight acts by using both internal physiological state and external context to make more holistic decisions about when intervention is truly necessary.

### How we built it

4sight pairs a Bangle.js 2 smartwatch with Meta Ray-Ban smart glasses to continuously capture two streams of data: biometric signals and environmental context via CV. The watch's custom-built firmware records 60-second windows of raw PPG (25 Hz) and accelerometer (12.5 Hz) data in a compact binary format, syncing over BLE via the Nordic UART Service to our Expo/React Native app. On-device, a pure TypeScript XGBoost engine extracts 36 biosignal features from each window, including HRV time-domain metrics (SDNN, RMSSD, pNN50), Poincare non-linear measures, and motion energy, then runs nine trained models (five 4-class risk classifiers spanning stress, health, sleep fatigue, cognitive fatigue, and physical exertion, plus four regressors for overall susceptibility and time-to-risk) to produce real-time vulnerability scores with no network dependency and fast inference. These models were trained on over 70,000 instances drawn from multimodal physiological datasets including WESAD and PPG-DaLiA (Schmidt et al., 2018; Reiss et al., 2019), with a weighted risk aggregation layer that transforms domain-specific predictions into a single generalized vulnerability score. On the backend, the Ray-Bans stream live video frames over a WebSocket to a FastAPI server on Cloudflare Containers, which chunks them into 1-second windows and dispatches them to a Gemma 3 4B vision-language model (VLM) running on Modal (L40S GPU) for low-latency food and activity captioning. Both biometric features and vision captions land in a Cloudflare D1 database via idempotent uploads. A Cloudflare Worker cron fires every 60 seconds, pulling the latest biometric and caption windows and feeding them to GPT-4o-mini with structured JSON outputs to make an intervention decision. If the model says "yes," a contextual nudge is sent as an iMessage through the Interaction Company Poke API. We also integrated Screen Time APIs for device-level behavior control and programmatic purchasing workflows for proactive mitigation. The whole pipeline, from biometric capture to environmental scan to autonomous intervention, runs in real time with no user interaction required.

### Challenges we ran into

Real-Time Environmental and System Integration: Connecting wearable biometric streams and environmental context from Meta glasses to a live ML inference engine and intervention system without latency or cascading errors required careful architectural design. Training a Niche Prediction Model: There is no labeled dataset for impaired decision-making windows. We had to develop vulnerability detection using stress and physiological markers while preventing overfitting due to limited ground-truth signals in this niche field. Coordinating Autonomous Interventions: Designing a system that does not just notify but acts on its own required building safe thresholds and ensuring interventions were context-aware rather than disruptive.

### Accomplishments we're proud of

Building a fully autonomous monitoring to prediction to intervention pipeline Successfully integrating real-time biometric data from a hackable smartwatch Designing a weighted multi-domain risk model rather than relying on a single metric Creating a system that can actively modify digital behavior instead of passively displaying data Most importantly, we transformed wearable biometrics into real decision-support infrastructure that works with you, not for you.

### What we learned

Most of us had never worked with biometric monitoring, hackable smartwatches, or autonomous intervention systems before. We learned how to handle noisy physiological data, build sliding-window ML models, and architect real-time systems that connect hardware to actionable outcomes. We also saw firsthand how powerful multidisciplinary collaboration can be. 4sight sits at the intersection of machine learning, systems engineering, behavioral science, and product design. All of this only worked because we brought those perspectives together.

### What's next

We plan to expand contextual intelligence to detect overstimulating or high-risk environments where cognitive clarity is critical. We’re also exploring medical integrations, including Continuous Glucose Monitoring (CGM) systems for diabetic patients. By combining glucose trend data with physiological stress modeling, 4sight could help predict and manage hypo- and hyperglycemic swings proactively. Long term, we envision 4sight as a generalized autonomous safety layer, one that connects biometric monitoring, environmental awareness, and real-world intervention pathways, including rapid connection to healthcare providers when risk escalates. References Starcke, K., & Brand, M. (2012). Decision making under stress: A selective review. Neuroscience & Biobehavioral Reviews, 36(4), 1228–1248. https://doi.org/10.1016/j.neubiorev.2012.02.003 Schmidt, P., Reiss, A., Dürichen, R., Marberger, C., & Van Laerhoven, K. (2018). Introducing WESAD, a Multimodal Dataset for Wearable Stress and Affect Detection. Proceedings of the 20th ACM International Conference on Multimodal Interaction (ICMI ’18), 400–408. https://doi.org/10.1145/3242969.3242985 Reiss, A., Indlekofer, I., & Schmidt, P. (2019). PPG-DaLiA [Dataset]. UCI Machine Learning Repository. https://doi.org/10.24432/C53890

## README (from the GitHub repository)

No README available.

## Detected evidence (automated analysis)

Indexed codebase: 189 recognized source files, 1194 KB.
- FastAPI (technology) — detected in the code
- JavaScript (language) — detected in the code
- Kotlin (language) — detected in the code
- Python (language) — detected in the code
- PyTorch (technology) — detected in the code
- React (technology) — detected in the code
- SQL (language) — detected in the code
- Swift (language) — detected in the code
- TypeScript (language) — detected in the code
- AI coding agent: Claude Code — evidence: config files committed to the repository; commit authorship or trailers
- AI coding agent: Codex — evidence: config files committed to the repository
- AI coding agent: Cursor — evidence: config files committed to the repository

## Codebase structure (from repository index)

### Files (120 of 217)

```
.agents/skills/vercel-react-native-skills/AGENTS.md
.agents/skills/vercel-react-native-skills/rules/animation-derived-value.md
.agents/skills/vercel-react-native-skills/rules/animation-gesture-detector-press.md
.agents/skills/vercel-react-native-skills/rules/animation-gpu-properties.md
.agents/skills/vercel-react-native-skills/rules/design-system-compound-components.md
.agents/skills/vercel-react-native-skills/rules/fonts-config-plugin.md
.agents/skills/vercel-react-native-skills/rules/imports-design-system-folder.md
.agents/skills/vercel-react-native-skills/rules/js-hoist-intl.md
.agents/skills/vercel-react-native-skills/rules/list-performance-callbacks.md
.agents/skills/vercel-react-native-skills/rules/list-performance-function-references.md
.agents/skills/vercel-react-native-skills/rules/list-performance-images.md
.agents/skills/vercel-react-native-skills/rules/list-performance-inline-objects.md
.agents/skills/vercel-react-native-skills/rules/list-performance-item-expensive.md
.agents/skills/vercel-react-native-skills/rules/list-performance-item-memo.md
.agents/skills/vercel-react-native-skills/rules/list-performance-item-types.md
.agents/skills/vercel-react-native-skills/rules/list-performance-virtualize.md
.agents/skills/vercel-react-native-skills/rules/monorepo-native-deps-in-app.md
.agents/skills/vercel-react-native-skills/rules/monorepo-single-dependency-versions.md
.agents/skills/vercel-react-native-skills/rules/navigation-native-navigators.md
.agents/skills/vercel-react-native-skills/rules/react-compiler-destructure-functions.md
.agents/skills/vercel-react-native-skills/rules/react-compiler-reanimated-shared-values.md
.agents/skills/vercel-react-native-skills/rules/react-state-dispatcher.md
.agents/skills/vercel-react-native-skills/rules/react-state-fallback.md
.agents/skills/vercel-react-native-skills/rules/react-state-minimize.md
.agents/skills/vercel-react-native-skills/rules/rendering-no-falsy-and.md
.agents/skills/vercel-react-native-skills/rules/rendering-text-in-text-component.md
.agents/skills/vercel-react-native-skills/rules/scroll-position-no-state.md
.agents/skills/vercel-react-native-skills/rules/state-ground-truth.md
.agents/skills/vercel-react-native-skills/rules/ui-expo-image.md
.agents/skills/vercel-react-native-skills/rules/ui-image-gallery.md
.agents/skills/vercel-react-native-skills/rules/ui-measure-views.md
.agents/skills/vercel-react-native-skills/rules/ui-menus.md
.agents/skills/vercel-react-native-skills/rules/ui-native-modals.md
.agents/skills/vercel-react-native-skills/rules/ui-pressable.md
.agents/skills/vercel-react-native-skills/rules/ui-safe-area-scroll.md
.agents/skills/vercel-react-native-skills/rules/ui-scrollview-content-inset.md
.agents/skills/vercel-react-native-skills/rules/ui-styling.md
.agents/skills/vercel-react-native-skills/SKILL.md
.claude/skills/vercel-react-native-skills
.cursor/skills/vercel-react-native-skills
.expo/devices.json
.expo/README.md
.github/workflows/check-backend.yml
.github/workflows/deploy-backend.yml
.gitignore
.pre-commit-config.yaml
4sight/.gitignore
4sight/.vscode/extensions.json
4sight/.vscode/settings.json
4sight/app.config.ts
4sight/app.json
4sight/app/_layout.tsx
4sight/app/(tabs)/_layout.tsx
4sight/app/(tabs)/foursight.tsx
4sight/app/(tabs)/index.tsx
4sight/app/(tabs)/trends.tsx
4sight/app/device.tsx
4sight/app/index.tsx
4sight/app/pairing.tsx
4sight/assets/models/risk_model.json
4sight/assets/models/test_vectors.json
4sight/components/charts/index.ts
4sight/components/charts/line-chart.tsx
4sight/components/charts/metric-card.tsx
4sight/components/charts/multi-line-chart.tsx
4sight/components/charts/radar-chart.tsx
4sight/components/RadarChart.tsx
4sight/components/TimeRuler.tsx
4sight/components/TrendGraph.tsx
4sight/components/ui/circular-score-ring.tsx
4sight/components/window-result-view.tsx
4sight/constants/sensor.ts
4sight/constants/theme.ts
4sight/eslint.config.js
4sight/features/api/client.ts
4sight/features/api/index.ts
4sight/features/api/upload.ts
4sight/features/bluetooth/bluetooth-manager.ts
4sight/features/feature-extraction/__tests__/accel-features.test.ts
4sight/features/feature-extraction/__tests__/hrv-features.test.ts
4sight/features/feature-extraction/__tests__/poincare-features.test.ts
4sight/features/feature-extraction/__tests__/quality-assessment.test.ts
4sight/features/feature-extraction/__tests__/rr-extraction.test.ts
4sight/features/feature-extraction/accel-features.ts
4sight/features/feature-extraction/binary-decoder.ts
4sight/features/feature-extraction/feature-extractor.ts
4sight/features/feature-extraction/hrv-features.ts
4sight/features/feature-extraction/index.ts
4sight/features/feature-extraction/poincare-features.ts
4sight/features/feature-extraction/ppg-preprocessing.ts
4sight/features/feature-extraction/quality-assessment.ts
4sight/features/feature-extraction/rr-extraction.ts
4sight/features/feature-extraction/types.ts
4sight/features/risk-prediction/__tests__/derived-features.test.ts
4sight/features/risk-prediction/__tests__/scaler.test.ts
4sight/features/risk-prediction/__tests__/xgboost-engine.test.ts
4sight/features/risk-prediction/derived-features.ts
4sight/features/risk-prediction/index.ts
4sight/features/risk-prediction/risk-predictor.ts
4sight/features/risk-prediction/scaler.ts
4sight/features/risk-prediction/types.ts
4sight/features/risk-prediction/xgboost-engine.ts
4sight/features/signal-processing/__tests__/clipping.test.ts
4sight/features/signal-processing/__tests__/filters.test.ts
4sight/features/signal-processing/__tests__/interpolation.test.ts
4sight/features/signal-processing/__tests__/spike-removal.test.ts
4sight/features/signal-processing/__tests__/statistics.test.ts
4sight/features/signal-processing/clipping.ts
4sight/features/signal-processing/filters/butterworth.ts
4sight/features/signal-processing/filters/hampel.ts
4sight/features/signal-processing/filters/median.ts
4sight/features/signal-processing/filters/savgol.ts
4sight/features/signal-processing/index.ts
4sight/features/signal-processing/interpolation.ts
4sight/features/signal-processing/spike-removal.ts
4sight/features/signal-processing/statistics.ts
4sight/features/signal-processing/types.ts
4sight/features/storage/index.ts
4sight/features/storage/local-store.ts
4sight/hooks/use-bluetooth.ts
[97 more files omitted for size]
```

### Dependencies

- 4sight/package.json: @expo-google-fonts/lato@^0.4.1, @expo-google-fonts/merriweather@^0.4.2, @expo/vector-icons@^15.0.3, @react-navigation/bottom-tabs@^7.4.0, @react-navigation/elements@^2.6.3, @react-navigation/native@^7.1.8, @types/react@~19.1.0, eslint@^9.25.0, eslint-config-expo@~10.0.0, expo@~54.0.33, expo-constants@~18.0.13, expo-file-system@~19.0.0, expo-font@~14.0.11, expo-haptics@~15.0.8, expo-image@~3.0.11, expo-linking@~8.0.11, expo-router@~6.0.23, expo-splash-screen@~31.0.13, expo-status-bar@~3.0.9, expo-symbols@~1.0.8, expo-system-ui@~6.0.9, expo-web-browser@~15.0.10, react@19.1.0, react-dom@19.1.0, react-native@0.81.5, react-native-ble-plx@^3.5.0, react-native-gesture-handler@~2.28.0, react-native-reanimated@~4.1.1, react-native-safe-area-context@~5.6.0, react-native-screens@~4.16.0, react-native-svg@^15.12.1, react-native-web@~0.21.0, react-native-worklets@0.5.1, typescript@~5.9.2, vitest@^4.0.18
- backend/pyproject.toml: fastapi@>=0.129.0, httpx@>=0.28.0, modal@>=0.77.0, uvicorn[standard]@>=0.40.0
- backend/worker/package.json: @cloudflare/containers@^0.1.0, @cloudflare/workers-types@^4.20250214.0, wrangler@^4.0.0
- biometric_model/requirements.txt: black@==23.11.0, fastapi@>=0.104.0,<1.0.0, flake8@==6.1.0, h5py, joblib@>=1.3.0, matplotlib@==3.8.2, modal@==0.63.32, numpy@==1.26.2, pandas@==2.1.3, pydantic@>=2.0.0,<3.0.0, pyedflib@==0.1.36, pytest@>=7.4.0, pytest-cov@==4.1.0, python-dotenv@==1.0.0, requests@>=2.31.0, scikit-learn@>=1.3.0,<2.0.0, scipy@>=1.11.0,<2.0.0, seaborn@==0.13.0, tensorboard@==2.15.1, torch@==2.1.0, torchvision@==0.16.0, tqdm@==4.66.1, uvicorn@==0.24.0, uvicorn[standard]@>=0.24.0,<1.0.0, wandb@==0.16.0, wfdb@==4.1.2, xgboost@==2.0.3
- package.json: @types/react@~19.1.10, react-native-svg@^15.15.3, typescript@~5.9.2

### Recent commits (newest first)

- Persist vision captions to D1 via Worker-level WebSocket interception
- Fix caption_store reading env vars at import time instead of call time
- Fix Poke nudge: use second person and exclude preface from delivery
- Prepend verbatim instruction to Poke nudge messages
- Use OpenAI structured outputs for intervention decisions
- trends stuff + backend stuff + help me
- Add unhealthy test payload docs for triggering interventions in prod
- Send Poke nudge on intervention "yes" decision
- Merge pull request #1 from kl527/app-dev-test
- Merge branch 'main' into app-dev-test
- Refactor quick fixes display and adjust container margin
- changes to trends and radar & line graphs
- additional app components and graphs
- add landing page clock
- Refactor ExpoMetaGlassesModule to use MainActor for async configuration
- app.json
- meta glasses optimization
- Update app.json to rename application and adjust configuration
- Add 1-minute intervention cron loop with OpenAI gpt-4o-mini
- bundle id

## Key source files (fetched from GitHub, selected and truncated for size)

### CLAUDE.md

```markdown
remember to always do `git pull --rebase` before pushing because we're just all committing to trunk

if you're committing and pushing any backend changes, you should use gh cli to watch GHA cd action and make sure it passes.

if you're debugging prod issues, use `uv run modal` and `source ~/.env.local && npx wrangler` clis, e.g., `source ~/.env.local && npx wrangler containers logs foresight-backend`

the way we test the websocket endpoint in prod is with `uv run --with websockets ./backend/scripts/replay_video_to_vision_ws.py --url https://foresight-backend.jun-871.workers.dev --video /home/ben/Downloads/vid.mp4 --magic-word <ask_the_user>`

to test the D1 biometric upload endpoint in prod:
1. apply migrations: `source ~/.env.local && cd backend/worker && npx wrangler d1 migrations apply foresight-biometrics --remote`
2. POST to `/biometrics/upload` with `x-magic-word` header and a JSON body containing `windowId`, `timestamp`, `durationMs`, `qualityScore`, and any feature fields
3. verify rows: `source ~/.env.local && cd backend/worker && npx wrangler d1 execute foresight-biometrics --remote --command "SELECT * FROM biometric_windows ORDER BY id DESC LIMIT 5"`
4. re-send the same `windowId` to confirm idempotency (`INSERT OR IGNORE` should silently skip duplicates)

to trigger an intervention in prod (upload unhealthy biometrics + food caption, then wait for cron):

1. upload unhealthy biometrics:
```bash
curl -X POST https://foresight-backend.jun-871.workers.dev/biometrics/upload \
  -H "Content-Type: application/json" \
  -H "x-magic-word: <ask_the_user>" \
  -d '{
    "windowId": "unhealthy-test-'"$(date +%s)"'",
    "timestamp": '"$(date +%s%3N)"',
    "durationMs": 60000,
    "qualityScore": 0.92,
    "hrMean": 142,
    "hrStd": 38,
    "hrMin": 98,
    "hrMax": 185,
    "meanRR": 422,
    "sdnn": 18,
    "rmssd": 12,
    "pnn50": 4.2,
    "pnn20": 11.5,
    "cvnn": 0.042,
    "cvsd": 0.028,
    "medianRR": 415,
    "rangeRR": 380,
    "movementIntensity": 0.002,
    "accelEnergy": 12.5,
    "peakCount": 142,
    "validRRCount": 140,
    "riskPrediction": {
      "riskAssessment": {
        "stress": {"level": 3, "label": "High Risk", "confidence": 0.89},
        "health": {"level": 3, "label": "High Risk", "confidence": 0.85},
        "sleepFatigue": {"level": 2, "label": "Moderate Risk", "confidence": 0.72},
        "cognitiveFatigue": {"level": 2, "label": "Moderate Risk", "confidence": 0.68},
        "physicalExertion": {"level": 0, "label": "No Risk", "confidence": 0.91}
      },
      "overallSusceptibility": 0.82,
      "alertLevel": "CRITICAL ALERT",
      "timeToRiskMinutes": 4.5
    }
  }'
```

2. upload unhealthy food caption:
```bash
curl -X POST https://foresight-backend.jun-871.workers.dev/captions/upload \
  -H "Content-Type: application/json" \
  -H "x-magic-word: <ask_the_user>" \
  -d '{
    "windowId": "unhealthy-caption-'"$(date +%s)"'",
    "timestamp": '"$(date +%s%3N)"',
    "chunkStartS": 0,
    "chunkEndS": 5,
    "
[truncated — 2507 more characters]
```

### backend/CLAUDE.md

```markdown
# backend/

FastAPI app + Cloudflare Worker proxy. Python 3.12, managed with uv.

## layout

- `app/main.py` — FastAPI app, mounts routers, has `/health` endpoint
- `app/models.py` — Pydantic request/response models (`SendMessageRequest`, `SendMessageResponse`)
- `app/routers/poke.py` — `POST /poke/send` — sends iMessage/SMS via Poke API. Reads API key from `x-poke-api-key` header (injected by Worker). Returns 500 if key missing, 502 on upstream failure.
- `app/routers/vision.py` — `WebSocket /vision/stream` — receives binary video frames from Meta Ray-Bans, sends per-frame JSON acks `{frame, bytes}`, and adds optional inference fields (`caption`, `latency_ms`, `chunk_start_s`, `chunk_end_s`, `inference_error`) from chunked Modal VLM inference.
- `app/services/poke.py` — `PokeClient` async HTTP client. POSTs to `https://poke.com/api/v1/inbound-sms/webhook` with Bearer auth.
- `app/services/caption_store.py` — fire-and-forget POST of vision captions to the Worker's `/captions/upload` D1 endpoint. Reads `WORKER_BASE_URL` and `MAGIC_WORD` from container env vars; no-ops if unset.
- `app/services/vision_inference.py` — Modal SDK client/session abstraction with no-op fallback when Modal credentials are missing.
- `modal/gemma3_vlm_app.py` — Modal app/class (`Gemma3VLMSession`) for stateful Gemma 3 chunk inference.
- `modal/streaming_vlm_app.py` — legacy StreamingVLM app retained for rollback.
- `worker/` — Cloudflare Worker (TypeScript). Handles auth via magic word, forwards secrets as headers to the container. Uses Durable Objects for container lifecycle.
- `tests/` — pytest suite (unit + integration). Run with `make check`.

## commands

```sh
uv sync --group dev   # install deps
make check            # run tests with coverage
```

## testing

pytest with pytest-asyncio (auto mode). Tests use `httpx.ASGITransport` for async HTTP tests and `starlette.testclient.TestClient` for WebSocket tests. External services are mocked — never call real APIs in tests.

## deployment

Pushes to `main` touching `backend/**` trigger `.github/workflows/deploy-backend.yml` which deploys the Worker to Cloudflare. A separate CI check (`.github/workflows/check-backend.yml`) runs `make check` on pushes and PRs.

Worker secrets for vision inference:

- `FORESIGHT_MODAL_TOKEN_ID`
- `FORESIGHT_MODAL_TOKEN_SECRET`
- `FORESIGHT_MODAL_APP_NAME` (optional override)
- `FORESIGHT_MODAL_CLASS_NAME` (optional override)
- `WORKER_BASE_URL` (auto-derived from Cloudflare API in CD; used by container to POST captions back to Worker)
- `OPENAI_API_KEY` (used by the intervention cron to call gpt-4o-mini)

CD deploy order (`.github/workflows/deploy-backend.yml`):

1. Deploy Modal app (`backend/modal/gemma3_vlm_app.py`) to Modal.
2. Sync Worker secrets (including Modal credentials + app/class).
3. Deploy Worker.

Optional CI variable:

- `FORESIGHT_MODAL_ENVIRONMENT` (Modal environment name; defaults to `main`).
- `FORESIGHT_GEMMA3_HF_SECRET_NAME` (optional Modal secret name that includes `H
[truncated — 2053 more characters]
```

### package.json

```
{
  "dependencies": {
    "react-native-svg": "^15.15.3"
  },
  "devDependencies": {
    "@types/react": "~19.1.10",
    "typescript": "~5.9.2"
  }
}

```

### backend/Dockerfile

```
FROM python:3.12-slim

COPY --from=ghcr.io/astral-sh/uv:latest /uv /usr/local/bin/uv

WORKDIR /app

COPY pyproject.toml uv.lock ./
RUN uv sync --frozen --no-dev

COPY app/ app/

EXPOSE 8080

ENV PATH="/app/.venv/bin:${PATH}"

CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "8080"]

```

### backend/pyproject.toml

```
[project]
name = "backend"
version = "0.1.0"
description = "Add your description here"
readme = "README.md"
requires-python = ">=3.12"
dependencies = [
    "fastapi>=0.129.0",
    "uvicorn[standard]>=0.40.0",
    "httpx>=0.28.0",
    "modal>=0.77.0",
]

[dependency-groups]
dev = [
    "pytest>=8.0",
    "pytest-asyncio>=0.25",
    "pytest-cov>=6.0",
]

[tool.pytest.ini_options]
asyncio_mode = "auto"
testpaths = ["tests"]

```

### biometric_model/requirements.txt

```
# Core ML libraries
torch==2.1.0
torchvision==0.16.0

# Data processing
pandas==2.1.3
numpy==1.26.2
scipy==1.11.4
scikit-learn>=1.3.0,<2.0.0
xgboost==2.0.3
joblib>=1.3.0


# Visualization
matplotlib==3.8.2
seaborn==0.13.0

# Progress bars
tqdm==4.66.1

# Signal processing (for PPG/BVP analysis)
scipy==1.11.4

# Dataset acquisition (PhysioNet)
wfdb==4.1.2
pyedflib==0.1.36

# Model deployment (Modal)
modal==0.63.32

# Experiment tracking (optional)
wandb==0.16.0
tensorboard==2.15.1

# API/Web framework (for deployment)
fastapi==0.104.1
uvicorn==0.24.0
pydantic==2.5.0

# Testing
pytest==7.4.3
pytest-cov==4.1.0

# Code quality
black==23.11.0
flake8==6.1.0

# Utilities
python-dotenv==1.0.0
requests==2.31.0

h5py

# API server
fastapi>=0.104.0,<1.0.0
uvicorn[standard]>=0.24.0,<1.0.0
pydantic>=2.0.0,<3.0.0

# Optional but recommended
scipy>=1.11.0,<2.0.0  # For statistical tests

# Development/Testing (optional)
pytest>=7.4.0  # For unit tests
requests>=2.31.0  # For API testing


```

### 4sight/package.json

```
{
  "name": "4sight",
  "main": "expo-router/entry",
  "version": "1.0.0",
  "scripts": {
    "start": "expo start",
    "reset-project": "node ./scripts/reset-project.js",
    "android": "expo run:android",
    "ios": "expo run:ios",
    "web": "expo start --web",
    "lint": "expo lint",
    "test": "vitest run"
  },
  "dependencies": {
    "@expo-google-fonts/lato": "^0.4.1",
    "@expo-google-fonts/merriweather": "^0.4.2",
    "@expo/vector-icons": "^15.0.3",
    "@react-navigation/bottom-tabs": "^7.4.0",
    "@react-navigation/elements": "^2.6.3",
    "@react-navigation/native": "^7.1.8",
    "expo": "~54.0.33",
    "expo-constants": "~18.0.13",
    "expo-file-system": "~19.0.0",
    "expo-font": "~14.0.11",
    "expo-haptics": "~15.0.8",
    "expo-image": "~3.0.11",
    "expo-linking": "~8.0.11",
    "expo-router": "~6.0.23",
    "expo-splash-screen": "~31.0.13",
    "expo-status-bar": "~3.0.9",
    "expo-symbols": "~1.0.8",
    "expo-system-ui": "~6.0.9",
    "expo-web-browser": "~15.0.10",
    "react": "19.1.0",
    "react-dom": "19.1.0",
    "react-native": "0.81.5",
    "react-native-ble-plx": "^3.5.0",
    "react-native-gesture-handler": "~2.28.0",
    "react-native-reanimated": "~4.1.1",
    "react-native-safe-area-context": "~5.6.0",
    "react-native-screens": "~4.16.0",
    "react-native-svg": "^15.12.1",
    "react-native-web": "~0.21.0",
    "react-native-worklets": "0.5.1"
  },
  "devDependencies": {
    "@types/react": "~19.1.0",
    "eslint": "^9.25.0",
    "eslint-config-expo": "~10.0.0",
    "typescript": "~5.9.2",
    "vitest": "^4.0.18"
  },
  "private": true,
  "expo": {
    "autolinking": {
      "nativeModulesDir": "./modules"
    }
  }
}

```

### backend/worker/package.json

```
{
  "name": "4sight-backend-worker",
  "private": true,
  "scripts": {
    "dev": "wrangler dev",
    "deploy": "wrangler deploy"
  },
  "dependencies": {
    "@cloudflare/containers": "^0.1.0"
  },
  "devDependencies": {
    "@cloudflare/workers-types": "^4.20250214.0",
    "wrangler": "^4.0.0"
  },
  "pnpm": {
    "onlyBuiltDependencies": [
      "esbuild",
      "workerd"
    ]
  },
  "packageManager": "pnpm@10.10.0+sha512.d615db246fe70f25dcfea6d8d73dee782ce23e2245e3c4f6f888249fb568149318637dca73c2c5c8ef2a4ca0d5657fb9567188bfab47f566d1ee6ce987815c39"
}

```

### 4sight/app/index.tsx

```typescript
import { Redirect } from 'expo-router';

export default function Index() {
  return <Redirect href="/pairing" />;
}

```

### backend/app/main.py

```python
from fastapi import FastAPI

from app.routers import poke, vision

app = FastAPI(title="4sight", version="0.1.0")

app.include_router(poke.router)
app.include_router(vision.router)


@app.get("/health")
async def health():
    return {"status": "ok"}

```

[174 more indexed source files omitted to keep this export small. The full file list is in the Codebase structure section above.]