๐ง 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 ofinhale/hold/exhale/restphases with per-phase durations, written instructions, and voice promptsspokenSummaryโ 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:
- Siri voice command triggers
StressExerciseIntent(anAppIntentwithopenAppWhenRun = true) - 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
UserDefaultsunderlast_exercise_plan - If health data is unavailable or stress is low, the fallback 4-7-8 breathing plan is persisted instead
- Fetches live health metrics via
- The Intent returns a dialog response (e.g., "I've created a personalized exercise for you") and the app opens
- The App entry point (
NeuroSyncv2App.swift) detects the persisted plan viacheckForPendingExercise()โ called ononAppearand every timeUIApplication.didBecomeActiveNotificationfires (covering cold launch, foreground-from-background, and Siri dismissal) checkForPendingExercise()reads the plan fromUserDefaults, clears it, and setsdashboardVM.showExerciseSheet = true- The
BreathingExerciseViewopens as a full-screen cover with voice guidance
Background Task Integration
The background task (BGTaskScheduler) also generates exercise plans autonomously:
- In the background, the system fetches metrics and runs stress analysis via NIM
- If stress is high, it generates an exercise plan and saves it to
UserDefaults(last_exercise_plan) - 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:
.playbackmode with.spokenAudioand.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:
- Dashboard โ stress indicator ring, AI insights card, live health metrics grid
- Sentiment โ social sentiment overview, channel breakdowns, message feed
- History โ searchable, filterable stress event log with detail view
- 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.3for 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
@MainActorViewModels with Combine publishers and async/await can feel clean when done right. TheDashboardViewModelcoordinating HealthKit, the NIM API, EventKit, and persistence all from one place was a design pattern that worked well. - Background tasks in iOS are finicky.
BGTaskSchedulerdoesn'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.gatherwithreturn_exceptions=Trueis 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
- Open
NeuroSyncv2.xcodeprojin Xcode - Update
AppConfig.serverBaseURLinModels/AppConfig.swiftto your Mac's local IP - Build and run on a physical iPhone (HealthKit doesn't work on simulator)
- 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.
Log in or sign up for Devpost to join the conversation.