Skip to content

feat: real-time Socket.IO alert broadcasting system#27

Merged
NadeeshaNJ merged 3 commits into
mainfrom
feature/realtime-alerts
May 11, 2026
Merged

feat: real-time Socket.IO alert broadcasting system#27
NadeeshaNJ merged 3 commits into
mainfrom
feature/realtime-alerts

Conversation

@izzathnisfer

Copy link
Copy Markdown
Contributor

Overview

This PR implements the real-time alert broadcasting system for the D2 Intelligence layer. It enables the backend to instantly notify connected clients (such as the D3 dashboard) when health anomalies are detected.

Key Changes

  • Socket.IO Integration: Added an ASGI-compatible Socket.IO server within the FastAPI application.
  • Real-time Broadcaster: Implemented a background Kafka consumer that listens to the alerts topic and broadcasts payloads to connected clients.
  • Alert Filtering: Updated the alert endpoints to support optional patient_id filtering, ensuring patients only see relevant alerts.
  • Observability: Added Prometheus counters to track alert delivery success and failure rates (d2_alerts_delivered_total, etc.).
  • Testing: Added a comprehensive suite of unit and integration tests (21 tests total) covering the Socket.IO bridge, alert payload generation, and database interactions.

Verification Results

  • Local Testing: All 21 tests passed successfully using pytest.
  • CI/CD: Verified successful build and test execution in GitHub Actions (Run #79).
  • Simulation: Verified functionality using the included scripts/simulate_alert.py script.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

@NadeeshaNJ NadeeshaNJ self-requested a review May 11, 2026 16:02

@NadeeshaNJ NadeeshaNJ left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice

@NadeeshaNJ NadeeshaNJ merged commit 900a958 into main May 11, 2026
7 of 8 checks passed
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.

3 participants