NeuroDecode AI is a real-time multimodal caregiving copilot for high-stress sensory moments.
It is designed for caregivers who need immediate support without typing. The app can listen, optionally observe with camera context, and respond with calm, actionable guidance in the same session.
Current implemented user flow:
- Choose
Audio onlyorVideo + audioin Support. - Select or enter a
Profile ID. - Start live session and speak with push-to-talk.
- Receive Gemini guidance (audio + transcript).
- Review post-session summary in History / Insights.
- Save suggested memories (trigger/follow-up) to profile memory.
Major capabilities already running:
- Multi-turn live session over WebSocket (
/ws/live). - Native Android PCM playback path for stable 24kHz output.
- Profile Workspace with structured support preferences.
- Retrieval-based profile memory context for live session personalization.
- Firestore-backed session history with fallback memory store.
- Suggested memory actions from History / Insights.
During sensory escalation, caregivers usually cannot stop and type long prompts.
NeuroDecode reduces caregiver cognitive load with a live loop:
- Hear context (mic stream).
- Optionally see context (camera observer mode).
- Respond instantly with practical support steps.
flowchart LR
A[Flutter Mobile App] -->|wss /ws/live| B[FastAPI Backend on Cloud Run]
B --> C[Gemini Live API]
B --> D[Audio Observer Model]
B --> E[Visual Observer Model]
B --> F[Firestore: sessions, events, profiles, memory, notifications, push tokens]
B --> G[Secret Manager]
B --> H[Firebase Admin SDK -> FCM]
D --> C
E --> C
F --> B
G --> B
H --> A
C -->|audio/transcript| A
NeuroDecode/
|- README.md
|- cloudbuild.yaml
|- neurodecode_backend/
| |- README.md
| |- requirements.txt
| |- scripts/
| | |- ws_smoke_test.py
| | |- memory_eval_probe.py
| |- app/
| | |- main.py
| | |- settings.py
| | |- gemini_live.py
| | |- ai_processor.py
| | |- push_sender.py
| | |- push_device_store.py
| | |- notification_store.py
| | |- rule_debug_store.py
| | |- models/
|- neurodecode_mobile/
|- README.md
|- pubspec.yaml
|- lib/
|- features/support/
|- features/live_agent/
|- features/home/
|- features/profile/
|- features/home/push_registration_service.dart
|- android/
|- app/build.gradle
|- settings.gradle
Requirements:
- Python 3.10+
- Gemini API key
- Optional Firestore credentials for local run
cd c:\PROJ\NeuroDecode\neurodecode_backend
python -m venv .venv
.\.venv\Scripts\python -m pip install --upgrade pip
.\.venv\Scripts\pip install -r requirements.txt
$env:GEMINI_API_KEY = "YOUR_KEY_HERE"
$env:NEURODECODE_SUMMARY_ENABLED = "1"
$env:NEURODECODE_SUMMARY_MODEL = "gemini-2.5-flash-lite"
$env:NEURODECODE_FIRESTORE_ENABLED = "1"
$env:NEURODECODE_ENABLE_PROFILE_MEMORY_CONTEXT = "1"
.\.venv\Scripts\python -m uvicorn app.main:app --reload --host 0.0.0.0 --port 8000Health check:
curl.exe -s http://127.0.0.1:8000/healthcd c:\PROJ\NeuroDecode\neurodecode_mobile
flutter pub get
flutter runSet backend host in:
neurodecode_mobile/lib/config/app_config.dart
Key HTTP endpoints:
GET /sessionsGET /sessions/latestGET /profiles/{profile_id}PUT /profiles/{profile_id}GET /profiles/{profile_id}/memoryPOST /profiles/{profile_id}/memoryGET /profiles/{profile_id}/memory-contextPOST /devices/push-tokenPOST /devices/push-token/deactivateGET /admin/rules/debug(admin token required)GET /admin/push/devices(admin token required)POST /admin/push/test(admin token required)
WebSocket:
GET /ws/live(query:user_id, optionalprofile_id)
Important server event:
profile_memory_statusindicates profile memory context is active for the session.
Core:
GEMINI_API_KEYNEURODECODE_LIVE_MODELNEURODECODE_RESPONSE_MODALITY
Memory / profile:
NEURODECODE_ENABLE_PROFILE_MEMORY_CONTEXTNEURODECODE_PROFILE_MEMORY_ITEM_LIMITNEURODECODE_PROFILE_MEMORY_SESSION_LIMIT
Summary / notifications:
NEURODECODE_SUMMARY_ENABLEDNEURODECODE_SUMMARY_MODELTELEGRAM_BOT_TOKENTELEGRAM_CHAT_ID
Firestore:
NEURODECODE_FIRESTORE_ENABLEDNEURODECODE_FIRESTORE_COLLECTIONNEURODECODE_FIRESTORE_EVENT_COLLECTIONNEURODECODE_FIRESTORE_PROFILE_COLLECTIONNEURODECODE_FIRESTORE_PROFILE_MEMORY_COLLECTIONNEURODECODE_FIRESTORE_PROJECT
Admin debug (optional):
NEURODECODE_ADMIN_DEBUG_ENABLEDNEURODECODE_ADMIN_DEBUG_TOKENNEURODECODE_ADMIN_DEBUG_MAX_ITEMS
FCM push (optional, feature-flagged):
NEURODECODE_FCM_ENABLEDNEURODECODE_FIRESTORE_PUSH_DEVICE_COLLECTION
Use this sequence for safe activation without exposing secrets in git.
- Keep all new flags
OFFby default in production. - Store sensitive values in Secret Manager (do not hardcode in repo or
cloudbuild.yaml). - Enable admin debug first, verify output, then enable FCM.
Suggested Secret Manager names:
neurodecode-gemini-api-keyneurodecode-admin-debug-token
Cloud Run update (PowerShell) - baseline runtime (replace project/region/service as needed):
gcloud run services update neurodecode-backend `
--project gen-lang-client-0348071142 `
--region asia-southeast1 `
--platform managed `
--set-secrets GEMINI_API_KEY=neurodecode-gemini-api-key:latest `
--set-secrets NEURODECODE_ADMIN_DEBUG_TOKEN=neurodecode-admin-debug-token:latest `
--update-env-vars NEURODECODE_ADMIN_DEBUG_ENABLED=1,NEURODECODE_ADMIN_DEBUG_MAX_ITEMS=500,NEURODECODE_FCM_ENABLED=0,NEURODECODE_FIRESTORE_PUSH_DEVICE_COLLECTION=push_device_tokensEnable FCM after admin debug passes:
gcloud run services update neurodecode-backend `
--project gen-lang-client-0348071142 `
--region asia-southeast1 `
--platform managed `
--update-env-vars NEURODECODE_FCM_ENABLED=1Quick verification after update:
gcloud run services describe neurodecode-backend `
--project gen-lang-client-0348071142 `
--region asia-southeast1 `
--platform managed `
--format="yaml(spec.template.spec.containers[0].env)"If live session suddenly shows GEMINI_API_KEY is required, re-apply the --set-secrets GEMINI_API_KEY=... command above because Cloud Run runtime env is source-of-truth (local .env does not apply to Cloud Run).
Admin debug endpoint usage (read-only):
GET /admin/rules/debug?admin_token=<TOKEN>&profile_id=<PROFILE_ID>&limit=20
GET /admin/push/devices?admin_token=<TOKEN>&user_id=<USER_ID>&profile_id=<PROFILE_ID>&limit=20
POST /admin/push/test?admin_token=<TOKEN>&user_id=<USER_ID>&profile_id=<PROFILE_ID>
FCM activation checklist (after admin debug is healthy):
- Device registers token via
POST /devices/push-token. - If needed, deactivate stale token via
POST /devices/push-token/deactivate. - Use admin test push endpoint before enabling production fanout.
- Backend receives proactive notifications as usual.
- Turn on
NEURODECODE_FCM_ENABLED=1. - Verify push send count in Cloud Run logs (
[push] Sent proactive push ...).
Android Firebase setup required for token issuance:
- Add neurodecode_mobile/android/app/google-services.json from Firebase Console for app id
com.neurodecode.neurodecode_mobile. - Ensure Google Services Gradle plugin is enabled in neurodecode_mobile/android/settings.gradle and neurodecode_mobile/android/app/build.gradle.
- Rebuild app after adding file so
FirebaseMessaging.getToken()can return a valid token.
These are tracked and expected in current phase:
- Mid-response audio can still feel slightly slow on some devices.
- Camera preview may fail to initialize on certain OEM/driver combinations (retry fallback exists).
- FCM banner delivery depends on valid Firebase app setup (
google-services.json) and valid device token registration.
Run this checklist before each release/deploy that touches live session, prompt, or audio path.
- Audio-only single turn
- Push-to-talk once (>1 second).
- Expect: transcript appears and AI audio response plays clearly.
- Audio-only multi-turn
- Send at least 3 turns in one session.
- Expect: no duplicated opening audio, no robotic slowdown, state transitions stay normal.
- Video observer on
- Start
Video + audiomode. - Pause/resume and drag observer preview.
- Expect: camera controls work, live response still stable.
- Start
- Session summary persistence
- End session normally.
- Expect: summary record saved and visible via
/sessions/latest.
- History / Insights rendering
- Open History screen in app.
- Expect: latest summary fields load and render correctly.
- Profile memory context handshake
- Start live with valid Profile ID.
- Expect:
profile_memory_statusappears and memory cues are shown when available.
- Proactive notifications baseline
- After eligible session data, open notifications center.
- Expect: unread/read behavior works and references correct session/profile.
Suggested status format per item: PASS, FAIL, N/A.
- Video NN reference: https://github.com/AutismBrainBehavior/Video-Neural-Network-ASD-screening
- Audio NN reference: https://github.com/AutismBrainBehavior/Audio-Neural-Network-ASD-screening
- Training notebook:
asd_agent_training.ipynb