A real-time health data pipeline using Redis Streams, RedisJSON, RediSearch, Pub/Sub, and a beautiful Tailwind/Next.js dashboard.
-
Node.js v16+
-
Redis 8 instance with modules:
- RedisJSON
- Redis Streams
- RediSearch
- (Optional) RedisAI
-
Environment variable
export REDIS_URL="redis://default:<PASSWORD>@<HOST>:<PORT>"
Emits synthetic patient vitals into patients:stream.
cd vital-sense-generator
npm install
npm startYou’ll see logs like:
Emitted <streamId> { patientId: 'P01', hr: 82, spo2: 95, sys: 120, dia: 80 }
Reads from patients:stream, writes snapshots to patient:<ID>:snapshot, and
acknowledges.
cd vital-sense-consumer
npm install
npm startYou’ll see:
✔ Consumer group "consumer-group" created on "patients:stream"
▶ Listening for new entries…
🗂 Got 1 msg(s) from stream "patients:stream"
✅ Processed <streamId> → patient:P01:snapshot { hr: '82', spo2: '95', sys: '120', dia: '80' }
Drop & recreate the snapshots index to cover all patient:*:snapshot keys.
# in vital-sense-consumer/
npm run create-indexExpected output:
Dropped existing idx:snapshots
✅ Index idx:snapshots created
Polls the index and publishes critical alerts to alerts:critical.
# in vital-sense-consumer/
npm run watch-alertsLogs every 5 s:
Watching for critical patients (SpO₂ <= 92)…
🚨 Alert published for patient:P02
Forwards alerts:critical messages to browser WebSockets on port 8080.
# in vital-sense-consumer/
npm run ws-proxyYou’ll see:
WebSocket proxy listening on ws://localhost:8080
Subscribed to alerts:critical
Proxy received: {"id":"P02","snapshot":{…}}
Fully featured, dark/light-toggleable, animated dashboard.
cd vitalsense-dashboard
npm install
npm run devOpen http://localhost:3000 and in the browser console you should see:
Opening WS…
✅ Vitals WS open
📬 WS message {...}
-
Stream key mismatch
- Generator writes to
patients:stream. - Consumer and index use the same key.
- Generator writes to
-
Consumer logs
- Look for “🗂 Got …” and “✅ Processed …”.
-
Index data
redis-cli -u "$REDIS_URL" FT.SEARCH idx:snapshots '*'
-
Alerts published
- Watch
npm run watch-alertsfor “🚨 Alert published”.
- Watch
-
WebSocket connectivity
- Proxy logs “Proxy received”.
- Dashboard console logs “WS open” + “WS message”.