Junction Wearable Integration
How reflex-junction connects wearable health data to Syntropy-Journals.
Package: reflex-junction (PyPI: pip install reflex-junction)
Status: Active — 5 providers available (Oura, WHOOP, Fitbit, Garmin, Dexcom)
Architecture
Environment Variables
| Variable | Required | Default | Description |
|---|---|---|---|
JUNCTION_API_KEY | No | (empty) | Junction/Vital API key. If absent, all wearable features are silently disabled. |
JUNCTION_ENVIRONMENT | No | sandbox | One of: sandbox, production, sandbox_eu, production_eu |
envs/base (shared) or envs/dev (override):
How It’s Wired
1. JunctionService (lifecycle)
syntropy_journals/app/api/services/junction_service.py — a BaseService registered in the ServiceRegistry alongside LLM, Chat, Diet, and Slack services.
initialize_sync()— reads env vars at module import time (before async loop)wire_reflex_app(app)— callsjunction.wrap_app()if API key is presentis_available— property used by other code to check if Junction is active
syntropy_journals/syntropy_journals.py after rx.App() creation:
2. Clerk → Junction user bridge
syntropy_journals/app/states/app/settings/_processes.py — bridge_junction_user() handler:
- Runs on Settings page
on_load - Gets
clerk_user_idfromAuthState - Creates a Junction user mapped to that ID (one-time, idempotent)
- Wrapped in try/except for graceful degradation
3. Settings page Link modal
syntropy_journals/app/components/shared/integration_cards.py — junction_link_modal():
- Opens when user clicks “Connect” on an available provider card
- Shows
junction_link_buttonwith a generated link token - On success,
JunctionState.on_provider_connectedfires (auto-refreshes providers)
4. Diet scoring wearable bonus
syntropy_journals/app/functions/diet/scoring.py — compute_wearable_bonus():
- Additive bonus (0-15 points) on top of the diet base score (0-100)
- Sleep quality: avg sleep score / 10, max 10 pts
- Activity level: avg daily steps / 2000, max 5 pts
- Users without wearables get bonus = 0 (no regression)
composite = min(diet_base + wearable_bonus, 100)
Available Providers
| Provider | ID | Type | Junction-supported |
|---|---|---|---|
| Oura Ring | oura | wearable | Yes (beta) |
| WHOOP | whoop | wearable | Yes |
| Fitbit | fitbit | wearable | Yes |
| Garmin | garmin | wearable | Yes |
| Dexcom CGM | dexcom | cgm | Yes |
| Apple Health | apple_health | app | Coming soon |
| Google Health Connect | google_health_connect | app | Coming soon |
| Epic MyChart | epic_mychart | ehr | Coming soon |
| Gmail Receipts | gmail_receipts | Coming soon |
Testing
Related PRs
- #101 — initial wiring + wearable scoring
- #104 — Link widget, Clerk bridge, JunctionService
- reflex-junction #4 — Phase 2+4 (Link widget, guard components)