๐Ÿง  NeuroSync โ€” AI-Powered Stress Intelligence

NeuroSync is an iOS application that fuses real-time physiological data from Apple HealthKit with AI-driven social sentiment analysis to give you a holistic picture of your stress levels. It doesn't just track how your body feels โ€” it also monitors your digital communications (Discord, email) to understand what's stressing you out and takes action when you need it most.


๐Ÿ“ฑ What it does

NeuroSync is split into four major layers that work together:

1. Physiological Stress Monitoring (iOS + HealthKit)

The iOS app reads seven health metrics from Apple HealthKit:

  • Heart Rate โ€” resting and current
  • Heart Rate Variability (HRV) โ€” the gold standard for stress detection
  • Sleep Hours โ€” how much rest you actually got
  • Step Count โ€” daily activity baseline
  • Exercise Minutes โ€” active energy expenditure
  • Mindful Minutes โ€” meditation / breath work
  • Respiratory Rate โ€” breathing patterns

These metrics are sent to NVIDIA's Nemotron-3 Ultra 550B model (via the NIM API) for analysis. The LLM returns a structured assessment:

  • Stress Level (low / moderate / high)
  • Confidence Score
  • Clinical Reasoning (why it thinks what it thinks)
  • Actionable Suggestion (what you can do about it)

If stress levels are high, NeuroSync automatically creates an iOS Reminder with the AI's suggestion โ€” so you get a push notification like "Try a 5-minute breathing exercise: inhale for 4 seconds, hold for 4, exhale for 6."

2. Social Sentiment Monitoring (Server + OpenClaw)

The backend server runs an OpenClaw orchestrator that polls Discord and Gmail every 15 seconds, feeding every message through an LLM stress analyser. It detects:

  • Urgent messages and crisis events in real-time
  • Sentiment trends across channels and senders
  • Volume anomalies โ€” sudden spikes in message traffic
  • Cross-channel stress aggregation โ€” is everyone stressed or just one channel?

The iOS app polls this server and displays a real-time social sentiment dashboard alongside your health data. If the server detects a social crisis, the app creates a reminder and correlates social stress with physiological stress (Health: high / Social: critical).

3. AI-Powered Breathing Exercises with ๐ŸŽ™๏ธ Siri Integration {#siri-integration}

When NeuroSync detects moderate or high stress (from either health data or social sentiment), it doesn't just warn you โ€” it actively intervenes with a personalized, LLM-generated guided breathing exercise. Here's how it works:

Voice-Guided Breathing (LLM-Generated)

The NVIDIA NIM API generates a custom StressExercisePlan with:

  • Personalized timing โ€” inhale/hold/exhale ratios tuned to your current heart rate and HRV
  • Thematic instructions โ€” wave visualizations for social stress, mountain grounding for health stress
  • Voice prompts for each phase, spoken aloud by the built-in VoiceGuidanceService (AVSpeechSynthesizer)

Each plan includes:

  • name โ€” e.g., "Ocean Breaths" or "The Wave Reset"
  • phases โ€” an array of inhale / hold / exhale / rest phases with per-phase durations, written instructions, and voice prompts
  • spokenSummary โ€” a natural-language description Siri reads aloud (e.g., "Your heart rate is elevated at 92. I've designed a 3-minute exercise called 'Ocean Breaths' for you.")

Fallback plan: If the LLM is unavailable (no API key, network failure), the app falls back to a hardcoded 4-7-8 breathing plan โ€” so the exercise always works.

The Full-Screen Breathing Experience

The BreathingExerciseView provides a full-screen, distraction-free environment:

Element Description
Animated breathing circle Expands on inhale, contracts on exhale โ€” smooth, color-shifting transitions
Phase instructions Large text showing what to do ("Breathe in slowly through your nose")
Countdown timer Large numeric display of seconds remaining in each phase
Progress bar Shows overall exercise progress (e.g., "23s / 120s")
Pause / Resume / Skip Full state machine: idle โ†’ active โ†’ paused โ†’ completed
Auto-dismiss On completion, shows a checkmark + "Great job!" and auto-closes after 3 seconds

๐ŸŽ™๏ธ Siri Integration (iOS 17+ App Intents)

NeuroSync registers App Shortcuts via the AppShortcutsProvider protocol, allowing users to trigger guided breathing exercises hands-free with Siri. The following phrases are automatically registered when the app is installed:

Phrase Action
"Hey Siri, start a NeuroSync stress exercise" Opens app & begins breathing exercise
"Hey Siri, start a breathing exercise with NeuroSync" Opens app & begins breathing exercise
"Hey Siri, begin a stress relief exercise on NeuroSync" Opens app & begins breathing exercise
"Hey Siri, help me de-stress with NeuroSync" Opens app & begins breathing exercise
"Hey Siri, do a breathing exercise with NeuroSync" Opens app & begins breathing exercise

How the Siri flow works:

  1. Siri voice command triggers StressExerciseIntent (an AppIntent with openAppWhenRun = true)
  2. The Intent itself runs the full HealthKit โ†’ NIM pipeline inside the app's own process:
    • Fetches live health metrics via HealthKitService
    • Sends them to NVIDIA NIM for stress analysis + exercise generation
    • If the LLM generates a plan, it's encoded to JSON and saved to UserDefaults under last_exercise_plan
    • If health data is unavailable or stress is low, the fallback 4-7-8 breathing plan is persisted instead
  3. The Intent returns a dialog response (e.g., "I've created a personalized exercise for you") and the app opens
  4. The App entry point (NeuroSyncv2App.swift) detects the persisted plan via checkForPendingExercise() โ€” called on onAppear and every time UIApplication.didBecomeActiveNotification fires (covering cold launch, foreground-from-background, and Siri dismissal)
  5. checkForPendingExercise() reads the plan from UserDefaults, clears it, and sets dashboardVM.showExerciseSheet = true
  6. The BreathingExerciseView opens as a full-screen cover with voice guidance

Background Task Integration

The background task (BGTaskScheduler) also generates exercise plans autonomously:

  1. In the background, the system fetches metrics and runs stress analysis via NIM
  2. If stress is high, it generates an exercise plan and saves it to UserDefaults (last_exercise_plan)
  3. When the user opens the app, checkForPendingExercise() detects the pre-generated plan and presents it immediately โ€” no loading, no waiting

VoiceGuidanceService

The VoiceGuidanceService wraps AVSpeechSynthesizer with a calming voice configuration:

  • Speech rate: 0.45 (slower than default for calmness)
  • Pitch multiplier: 1.1 (slightly warmer tone)
  • Audio session: .playback mode with .spokenAudio and .duckOthers โ€” plays even when the device is in silent mode
  • Pause / Resume / Stop โ€” full voice lifecycle management tied to the exercise state machine

4. Simulation & Demo Mode

Because not everyone has a Discord bot token and a Gmail OAuth setup handy, NeuroSync includes a standalone simulator server that generates 1000+ realistic messages across multiple stress scenarios:

  • ๐ŸŸข normal_day โ€” moderate traffic, occasional spikes
  • ๐Ÿ”ด incident_escalation โ€” starts calm, builds to crisis, resolves
  • ๐ŸŸข weekend_calm โ€” very low traffic, positive vibes
  • ๐Ÿ”ด crisis_spike โ€” sudden massive burst, then decline
  • ๐ŸŸก gradual_buildup โ€” slow burn over time
  • ๐Ÿ”ด rollercoaster โ€” alternating high/low stress
  • ๐Ÿ”ด sustained_pressure โ€” consistent high volume & stress

You can switch scenarios live via API to demo different stress patterns.


๐Ÿ—๏ธ How we built it

Frontend: iOS (SwiftUI)

Component Technology
UI Framework SwiftUI with NavigationStack, TabView
State Management @MainActor ViewModels, @Published, @EnvironmentObject
Health Data HealthKit (HKHealthStore, HKObserverQuery)
Reminders EventKit (EKReminder, EKAlarm)
Secure Storage iOS Keychain (API key storage)
Background Tasks BGTaskScheduler for periodic stress checks
Auto-refresh Task-based polling loop (5 min health, 30s social)
Siri Integration AppIntents framework โ€” AppShortcutsProvider, AppIntent with openAppWhenRun
Voice Guidance AVSpeechSynthesizer + AVAudioSession (plays in silent mode)
Breathing Exercise Engine State machine (StressExerciseManager) with timer-driven phase transitions

The iOS app has four tabs:

  1. Dashboard โ€” stress indicator ring, AI insights card, live health metrics grid
  2. Sentiment โ€” social sentiment overview, channel breakdowns, message feed
  3. History โ€” searchable, filterable stress event log with detail view
  4. Settings โ€” NVIDIA API key management, permissions, data management

Backend: Python + OpenClaw + FastAPI

Component Technology
Orchestrator Async Python with asyncio
Message Polling OpenClaw CLI + SDK (Discord, Gmail)
LLM Analysis OpenClaw agent โ†’ any LLM (GPT-4o-mini, Claude, etc.)
Fallback Engine Keyword-based heuristic analyser
Storage RollingBuffer + JSONL persistence
REST API FastAPI with Pydantic models
Simulation Standalone FastAPI server with scenario engine
HTTP Poller httpx AsyncClient for simulated polling

AI Stack

Model Provider Use Case
Nemotron-3 550B (NVIDIA NIM) NVIDIA API Physiological stress analysis (iOS โ†’ cloud)
GPT-4o-mini (or configurable) OpenClaw Gateway Social message sentiment analysis (server)

Architecture Diagram

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚                     iOS App (SwiftUI)                        โ”‚
โ”‚  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”  โ”‚
โ”‚  โ”‚   HealthKit   โ”‚  โ”‚  SocialMonitor   โ”‚  โ”‚   Reminders   โ”‚  โ”‚
โ”‚  โ”‚  (HR, HRV,   โ”‚  โ”‚  (polls server   โ”‚  โ”‚  (EventKit)   โ”‚  โ”‚
โ”‚  โ”‚   sleep, โ€ฆ)  โ”‚  โ”‚   every 30s)     โ”‚  โ”‚   auto-create โ”‚  โ”‚
โ”‚  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜  โ”‚
โ”‚         โ”‚                   โ”‚                    โ”‚          โ”‚
โ”‚         โ–ผ                   โ–ผ                    โ”‚          โ”‚
โ”‚  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”โ”‚          โ”‚
โ”‚  โ”‚        NVIDIA NIM (Nemotron-3 550B)          โ”‚โ”‚          โ”‚
โ”‚  โ”‚   "Given HR=88, HRV=24, sleep=5.2h โ†’        โ”‚โ”‚          โ”‚
โ”‚  โ”‚    stress=moderate, confidence=0.78"         โ”‚โ”‚          โ”‚
โ”‚  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜โ”‚          โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜          โ”‚
                       โ”‚ HTTP (REST)                          โ”‚
                       โ–ผ                                      โ”‚
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚             NeuroSync Server (FastAPI + OpenClaw)               โ”‚
โ”‚                                                                 โ”‚
โ”‚  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”   โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”   โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” โ”‚
โ”‚  โ”‚   Discord Poller  โ”‚   โ”‚  Gmail Pollerโ”‚   โ”‚ Simulated      โ”‚ โ”‚
โ”‚  โ”‚   (every 15s)    โ”‚   โ”‚  (every 15s)  โ”‚   โ”‚ HTTP Poller*   โ”‚ โ”‚
โ”‚  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜   โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜   โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ โ”‚
โ”‚           โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜         โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜           โ”‚
โ”‚                     โ–ผ                     โ–ผ                    โ”‚
โ”‚           โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”             โ”‚
โ”‚           โ”‚          MessageStore                 โ”‚            โ”‚
โ”‚           โ”‚  (Rolling buffer + JSONL persistence) โ”‚            โ”‚
โ”‚           โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜             โ”‚
โ”‚                              โ–ผ                                 โ”‚
โ”‚           โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”             โ”‚
โ”‚           โ”‚          StressAnalyser               โ”‚            โ”‚
โ”‚           โ”‚   (LLM agent OR keyword fallback)     โ”‚            โ”‚
โ”‚           โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜             โ”‚
โ”‚                              โ–ผ                                 โ”‚
โ”‚           โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”             โ”‚
โ”‚           โ”‚      Aggregated Summary              โ”‚            โ”‚
โ”‚           โ”‚  โ†’ REST API โ†’ iOS App               โ”‚            โ”‚
โ”‚           โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜             โ”‚
โ”‚                                                                 โ”‚
โ”‚  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”   โ”‚
โ”‚  โ”‚  OpenClaw Gateway (ws://127.0.0.1:18789)                โ”‚   โ”‚
โ”‚  โ”‚  Manages channels + routes LLM inference                โ”‚   โ”‚
โ”‚  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜   โ”‚
โ”‚                                                                 โ”‚
โ”‚  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”   โ”‚
โ”‚  โ”‚  Simulator Server (standalone, port 8081)                โ”‚   โ”‚
โ”‚  โ”‚  โ€ข 7 stress scenarios                                   โ”‚   โ”‚
โ”‚  โ”‚  โ€ข 1000+ realistic messages per seed                     โ”‚   โ”‚
โ”‚  โ”‚  โ€ข Live scenario switching via API                       โ”‚   โ”‚
โ”‚  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜   โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

*Simulated pollers used when NEUROSYNC_SIM_MODE=true

๐Ÿšง Challenges we ran into

1. HealthKit authorization is a multi-step dance. You can't just request access and assume it works. The first time a user opens the app, HealthKit prompts might not fire properly, and background HKObserverQuery callbacks require careful lifecycle management. We added a polling loop that waits up to 15 seconds for authorization before fetching data.

2. Getting reliable HRV data from HealthKit. HRV (Heart Rate Variability) is arguably the most important stress metric, but it's also the most sparse. Not all Apple Watch models record SDNN consistently, and some users may never have HRV data. We made all metrics optional and only run analysis when at least 3 metrics have real values.

3. LLM output parsing without the hallucinations. Getting the Nemotron model to return valid JSON every single time without markdown fences or stray characters required careful prompt engineering AND a defensive parser that strips ```json blocks, handles whitespace, and validates the output before treating it as a real analysis.

4. The OpenClaw gateway is a moving target. During development, the OpenClaw CLI's agent mode kept changing. We built a dual-path analyser: if the LLM agent is available, use it; if not, fall back to a keyword-based engine that scans for crisis signals, stress keywords, and sentiment markers. This made the system resilient to gateway issues.

5. Cross-device networking during the hackathon. The iOS app needs to reach the server running on a MacBook. We hardcoded a local IP (172.18.92.67) but this breaks as soon as you switch networks. The launch_demo.sh script now auto-detects the local IP and prints it for easy configuration.

6. iOS Reminders permissions changed in iOS 17. Apple introduced requestFullAccessToReminders() vs requestWriteOnlyAccessToReminders(), and the old requestAccess(to:) is deprecated. We had to add availability checks for both paths.

๐Ÿ“š What we learned

On the AI side:

  • Prompt engineering for structured JSON output is an art. You have to be absurdly specific ("Respond ONLY with valid JSON in this exact format โ€” no markdown, no code fences") and even then, you need defensive parsing.
  • Temperature matters. We used temperature: 0.3 for stress analysis because you want consistent, evidence-based results โ€” not creative interpretations.
  • Nemotron-3 550B is remarkably capable at medical-style reasoning with structured outputs.

On the iOS side:

  • SwiftUI's @MainActor ViewModels with Combine publishers and async/await can feel clean when done right. The DashboardViewModel coordinating HealthKit, the NIM API, EventKit, and persistence all from one place was a design pattern that worked well.
  • Background tasks in iOS are finicky. BGTaskScheduler doesn't guarantee execution timing, and the expiration handler must be handled with extreme care (we used a lock to prevent double-completion).

On the backend side:

  • asyncio.gather with return_exceptions=True is the right way to poll multiple channels concurrently without one failure bringing down the whole cycle.
  • A generic keyword fallback analyser is surprisingly effective. It doesn't match the nuance of an LLM, but it catches 80% of real crises with simple pattern matching.
  • Building a message generator with template banks and filler words produces far more realistic test data than random string generation.

๐Ÿ”ฎ What's next for NeuroSync

  • More health metrics: Add blood oxygen (SpO2), blood pressure (where available), and glucose data for richer physiological context
  • More social channels: Slack, Teams, WhatsApp โ€” the OpenClaw SDK theoretically supports them
  • On-device AI: Run a distilled model (e.g., via CoreML or Apple's MLX) directly on the iPhone for privacy-preserving stress analysis without sending health data to the cloud
  • Watch app: An Apple Watch companion that shows live stress levels and haptic feedback when the system detects a spike
  • Trend analysis: Show stress patterns over days/weeks/months โ€” "Your stress is highest on Tuesday afternoons"
  • Personalized interventions: Learn which suggestions work best for each user and tailor the AI's advice over time
  • Shared dashboards: Optionally share anonymized stress data with therapists or coaches
  • Calendar integration: Correlate stress spikes with calendar events โ€” "Your stress peaks during the weekly engineering standup"

๐Ÿ› ๏ธ Quick Start

iOS App

  1. Open NeuroSyncv2.xcodeproj in Xcode
  2. Update AppConfig.serverBaseURL in Models/AppConfig.swift to your Mac's local IP
  3. Build and run on a physical iPhone (HealthKit doesn't work on simulator)
  4. Get an NVIDIA API key from build.nvidia.com and enter it in Settings

Server (for social sentiment)

cd server

# Install dependencies
pip install -r requirements.txt

# Launch the full demo (simulator server + main server)
bash launch_demo.sh

# Or manually:
python3 simulator_server.py --port 8081 --scenario normal_day
python3 -m uvicorn main:app --host 0.0.0.0 --port 8080

Available Demo Scenarios

# Change scenario live:
curl -X POST "http://localhost:8081/sim/scenario?scenario=crisis_spike"
curl -X POST "http://localhost:8081/sim/scenario?scenario=weekend_calm"
curl -X POST "http://localhost:8081/sim/scenario?scenario=incident_escalation"

Server API Endpoints

Method Path Description
GET /health Server health check
GET /social/dashboard Full social sentiment dashboard (what the iOS app polls)
GET /social/messages Recent messages with sentiment
GET /social/urgent Urgent/crisis messages
POST /social/health-correlation Receive health stress from iOS
POST /social/create-reminder Queue a social stress reminder
GET /social/pending-reminders Poll pending reminders for iOS
GET /analysis/latest Latest aggregated stress analysis
GET /analysis/history Historical analyses
GET /sim/status Simulator status and scenario info
GET /sim/scenarios List all available scenarios

๐Ÿ“ Project Structure

NeuroSyncv2/
โ”œโ”€โ”€ NeuroSyncv2/                  # iOS App
โ”‚   โ”œโ”€โ”€ NeuroSyncv2App.swift      # App entry point + Siri & background task exercise plan detection
โ”‚   โ”œโ”€โ”€ ContentView.swift         # Tab navigation & root view
โ”‚   โ”œโ”€โ”€ Models/
โ”‚   โ”‚   โ”œโ”€โ”€ HealthMetrics.swift   # Health data model
โ”‚   โ”‚   โ”œโ”€โ”€ StressResult.swift    # LLM analysis result
โ”‚   โ”‚   โ”œโ”€โ”€ StressEvent.swift     # Stored stress check
โ”‚   โ”‚   โ”œโ”€โ”€ StressExercise.swift  # Exercise plan & phase models
โ”‚   โ”‚   โ”œโ”€โ”€ SocialMessage.swift   # Social message model
โ”‚   โ”‚   โ””โ”€โ”€ AppConfig.swift       # Global configuration
โ”‚   โ”œโ”€โ”€ Intents/                   # ๐ŸŽ™๏ธ Siri / App Intents
โ”‚   โ”‚   โ”œโ”€โ”€ NeuroSyncShortcuts.swift  # AppShortcutsProvider (5 Siri phrases)
โ”‚   โ”‚   โ””โ”€โ”€ StressExerciseIntent.swift # AppIntent (openAppWhenRun)
โ”‚   โ”œโ”€โ”€ Managers/                  # ๐Ÿง˜ Exercise engine
โ”‚   โ”‚   โ””โ”€โ”€ StressExerciseManager.swift  # State machine + timer + voice orchestration
โ”‚   โ”œโ”€โ”€ ViewModels/
โ”‚   โ”‚   โ”œโ”€โ”€ DashboardViewModel.swift
โ”‚   โ”‚   โ”œโ”€โ”€ SocialSentimentViewModel.swift
โ”‚   โ”‚   โ”œโ”€โ”€ StressHistoryViewModel.swift
โ”‚   โ”‚   โ””โ”€โ”€ SettingsViewModel.swift
โ”‚   โ”œโ”€โ”€ Views/
โ”‚   โ”‚   โ”œโ”€โ”€ DashboardView.swift
โ”‚   โ”‚   โ”œโ”€โ”€ BreathingExerciseView.swift   # Full-screen animated breathing UI
โ”‚   โ”‚   โ”œโ”€โ”€ StressIndicatorView.swift     # Custom ring gauge
โ”‚   โ”‚   โ”œโ”€โ”€ LlmSuggestionView.swift       # AI insights card
โ”‚   โ”‚   โ”œโ”€โ”€ MetricCardView.swift
โ”‚   โ”‚   โ”œโ”€โ”€ SocialSentimentView.swift
โ”‚   โ”‚   โ”œโ”€โ”€ MessageRowView.swift
โ”‚   โ”‚   โ”œโ”€โ”€ ChannelBreakdownCard.swift
โ”‚   โ”‚   โ”œโ”€โ”€ StressHistoryView.swift
โ”‚   โ”‚   โ””โ”€โ”€ SettingsView.swift
โ”‚   โ””โ”€โ”€ Services/
โ”‚       โ”œโ”€โ”€ HealthKitService.swift       # Apple Health integration
โ”‚       โ”œโ”€โ”€ NIMService.swift             # NVIDIA NIM API client + exercise generation
โ”‚       โ”œโ”€โ”€ SocialSentimentService.swift # Server API client
โ”‚       โ”œโ”€โ”€ VoiceGuidanceService.swift   # AVSpeechSynthesizer (calming voice)
โ”‚       โ”œโ”€โ”€ EventKitService.swift        # Reminders integration
โ”‚       โ”œโ”€โ”€ BackgroundTaskService.swift  # BGTaskScheduler + exercise plan storage
โ”‚       โ””โ”€โ”€ KeychainHelper.swift         # Secure API key storage
โ”œโ”€โ”€ server/                       # Python Backend
โ”‚   โ”œโ”€โ”€ main.py                   # FastAPI bridge server
โ”‚   โ”œโ”€โ”€ run_orchestrator.py       # CLI orchestrator runner
โ”‚   โ”œโ”€โ”€ simulator_server.py       # Standalone simulator
โ”‚   โ”œโ”€โ”€ launch_demo.sh            # One-command demo launcher
โ”‚   โ”œโ”€โ”€ orchestrator.yaml         # Example config
โ”‚   โ”œโ”€โ”€ requirements.txt          # Python dependencies
โ”‚   โ”œโ”€โ”€ orchestrator/
โ”‚   โ”‚   โ”œโ”€โ”€ orchestrator.py       # Main poll-analyse loop
โ”‚   โ”‚   โ”œโ”€โ”€ poller.py             # Discord + Gmail pollers
โ”‚   โ”‚   โ”œโ”€โ”€ simulated_http_poller.py  # HTTP simulator client
โ”‚   โ”‚   โ”œโ”€โ”€ analyser.py           # LLM + fallback analysis
โ”‚   โ”‚   โ”œโ”€โ”€ storage.py            # Rolling buffer persistence
โ”‚   โ”‚   โ”œโ”€โ”€ social_api.py         # Social sentiment REST API
โ”‚   โ”‚   โ””โ”€โ”€ config.py             # All configuration
โ”‚   โ””โ”€โ”€ simulator/
โ”‚       โ”œโ”€โ”€ generator.py          # Realistic message templates
โ”‚       โ”œโ”€โ”€ poller.py             # Scenario-based burst patterns
โ”‚       โ””โ”€โ”€ api.py                # Sim control endpoints
โ”œโ”€โ”€ Info.plist                    # App permissions & capabilities
โ””โ”€โ”€ .gitignore

๐Ÿงช Tech Stack Summary

Layer Technology
Mobile SwiftUI, HealthKit, EventKit, Keychain, BGTaskScheduler
๐ŸŽ™๏ธ Siri / App Intents AppIntents framework โ€” AppShortcutsProvider, AppIntent with openAppWhenRun
๐Ÿ—ฃ๏ธ Voice Guidance AVSpeechSynthesizer + AVAudioSession (plays in silent mode)
๐Ÿง˜ Exercise Engine Timer-driven state machine with pause/resume/skip lifecycle
AI (Physiological) NVIDIA NIM โ€” Nemotron-3 Ultra 550B
AI (Social) OpenClaw + GPT-4o-mini (configurable)
Backend Python, FastAPI, asyncio, httpx
Message Platform OpenClaw SDK / Gateway
Persistence Rolling buffers, JSONL, UserDefaults
Simulation Custom scenario engine with 1000+ message pools

Made with ๐Ÿง , too much coffee, and an Apple Watch that definitely knows when I'm stressed.

Built With

Share this project:

Updates