Skip to content

feat: Stellar Network Health Monitoring (#192)#198

Open
Peolite001 wants to merge 1 commit into
Lumina-eX:mainfrom
Peolite001:feat/stellar-network-health-monitoring
Open

feat: Stellar Network Health Monitoring (#192)#198
Peolite001 wants to merge 1 commit into
Lumina-eX:mainfrom
Peolite001:feat/stellar-network-health-monitoring

Conversation

@Peolite001

Copy link
Copy Markdown

📌 Pull Request

🔗 Related Issue

Closes #192


📝 Description

What does this PR do?
Implements Stellar Network Health Monitoring — a complete real-time monitoring system that checks Horizon API connectivity at regular intervals, tracks network status (healthy/degraded/unavailable), exposes a status endpoint for frontend consumption, logs outages and recovery events, and provides a responsive UI component to display current network status across the application.

Why is this change necessary?
AnonChat relies on the Stellar blockchain for wallet authentication, group creation, and on-chain verification. Users currently have no visibility into network availability. When Stellar is degraded or down, users see confusing failures without context. This PR provides transparency, graceful degradation, and clear messaging so users understand when network issues affect functionality.


🚀 Changes Made

  • Feature implemented:
    lib/stellar/health-monitor.ts — Core monitoring engine with automatic polling, status classification, outage detection, and structured logging
    app/api/stellar/health/route.ts — REST + SSE endpoint for real-time health status
    app/api/stellar/health/history/route.ts — Audit endpoint for outage history
    components/stellar-network-status.tsx — Reusable UI component (badge / banner / compact variants)
    lib/stellar/health-monitor.test.ts — Unit tests for connectivity checks and error handling
    app/api/stellar/health/route.test.ts — API route tests
  • Bug fixed:
  • Refactor:
  • Documentation updated:

🧪 Testing & Validation

  • Tested locally
  • No runtime errors
  • Existing features work as expected
  • Edge cases handled
    Unconfigured Stellar returns proper unavailable state with clear error message
    SSE fallback to polling when stream connection fails
    Multiple concurrent subscribers handled safely
    Outage start/end/duration accurately tracked and logged
    Component gracefully handles API downtime with retry button

⚠️ Breaking Changes

  • No breaking changes
  • Breaking changes exist (explain below)

If yes, explain:
N/A — All additions are net-new files and additive integrations. No existing APIs modified.


📋 Contributor Checklist (MANDATORY)

  • I was assigned to this issue
  • My code follows the project structure and conventions
  • I have tested my changes thoroughly
  • I did not introduce unnecessary dependencies
  • I have linked the issue (Closes #)
  • This PR is ready for review

💡 Notes for Reviewer

  • Key areas to review:
    lib/stellar/health-monitor.ts — Check the outage detection logic and status transition boundaries (healthy < 2s, degraded 2–5s, unavailable > 5s)
    app/api/stellar/health/route.ts — Verify SSE stream cleanup on client disconnect to prevent memory leaks
    components/stellar-network-status.tsx — Confirm responsive behavior: compact dot on mobile header, full banner on chat page, details hidden appropriately

  • Known limitations:
    Monitoring starts on first API request (lazy init). If no client ever hits /api/stellar/health, the background poller never starts. This is intentional to avoid unnecessary Horizon load on static pages.
    The STELLAR_SOURCE_SECRET env var is required for loadStellarConfig() to succeed, but health checks only need STELLAR_HORIZON_URL and STELLAR_NETWORK. Consider decoupling in a future refactor.
    Tests use vitest — ensure npm install -D vitest or equivalent is in the project's dev dependencies before running.

- Real-time Horizon API health checks with automatic polling
- Network status tracking: healthy, degraded, unavailable
- SSE endpoint /api/stellar/health for live frontend updates
- Outage detection with structured logging and recovery tracking
- /api/stellar/health/history for audit/debugging
- Responsive UI component with badge, banner, and compact variants
- Graceful fallback to polling when SSE unavailable
- Unit tests for connectivity checks and error handling
- Integrated into chat page banner and header compact indicator

Closes Lumina-eX#192
@drips-wave

drips-wave Bot commented Jun 23, 2026

Copy link
Copy Markdown

@Peolite001 Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

@SudiptaPaul-31

Copy link
Copy Markdown
Collaborator

@Peolite001 resolve conflicts

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.

Create Stellar Network Health Monitoring

2 participants