Skip to content

Real-time alert system complete implementation and fixes#26

Closed
izzathnisfer wants to merge 6 commits into
mainfrom
pr/alerts-integration
Closed

Real-time alert system complete implementation and fixes#26
izzathnisfer wants to merge 6 commits into
mainfrom
pr/alerts-integration

Conversation

@izzathnisfer

Copy link
Copy Markdown
Contributor

Summary

Implements the real-time alert broadcasting pipeline and auth-protected API routes for the D2 Intelligence layer.

Changes

Real-time Alert System (Socket.IO)

  • Added Socket.IO server mounted on /socket.io in app.py
  • Kafka consumer (_consume_alerts) broadcasts incoming alerts to all connected clients in real-time
  • Socket authentication via session token (configurable via socketio_require_auth)
  • Room-based subscriptions (join_room / leave_room events)

Auth-Protected Alerts Route

  • GET /api/alerts — doctors/admins see all alerts; patients see only their own
  • PATCH /api/alerts/{id}/acknowledge — restricted to doctor and admin roles
  • Logs acknowledgment with username and auth subject ID

Configuration

  • Added session_secret_key, cors_allow_origins, socketio_require_auth, socketio_allow_origins to Settings

Observability

  • New Prometheus counters: ALERTS_DELIVERED, ALERTS_DELIVERY_FAILED, ALERTS_ACKNOWLEDGED

Testing

  • Unit tests: alert payload builder, auth token extraction, origin splitting, alerts route
  • Integration tests: Socket.IO bridge, worker pipeline end-to-end

Scripts

  • scripts/simulate_alert.py — publishes test vitals payloads to Kafka for local testing

Commits

  • feat: implement real-time alert system with Socket.IO
  • feat: async handling and add unit tests for auth token extraction and origin splitting
  • feat: add simulate_alert script for publishing vitals payloads to Kafka

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant