Skip to content

Feature/backend circuit health api#576

Open
Emeka-12 wants to merge 4 commits into
StellaBridge:mainfrom
Emeka-12:feature/backend-circuit-health-api
Open

Feature/backend circuit health api#576
Emeka-12 wants to merge 4 commits into
StellaBridge:mainfrom
Emeka-12:feature/backend-circuit-health-api

Conversation

@Emeka-12
Copy link
Copy Markdown

@Emeka-12 Emeka-12 commented Jun 2, 2026

Summary

This PR adds the Circuit Health API for monitoring alerting and protection circuits across the Bridge-Watch platform.
Closes #522
Closes #523

Changes

New files:

  • backend/src/services/circuitHealth.service.ts — CircuitHealthService with Redis-cached queries for circuit states, transitions, and manual overrides
  • backend/src/api/routes/circuitHealth.ts — Five endpoints under /api/v1/circuit-health/:
  • GET /health — comprehensive health info for all scopes
  • GET /health/state — specific circuit state by scope/identifier
  • GET /health/transitions — filtered recent transitions
  • GET /health/overrides — whitelisted items
  • GET /health/cache/stats — cache performance metrics
  • backend/tests/services/circuitHealth.service.test.ts — 11 unit tests covering health retrieval, transitions, caching, whitelist, and error handling
  • docs/circuit-health-api.md — full API documentation with examples

Modified files:

  • backend/src/api/routes/index.ts — registers circuit health routes at /api/v1/circuit-health
  • backend/src/api/routes/accessOverview.routes.ts — fixes pre-existing build error (missing 400 response schema)

- Create CircuitHealthService with Redis caching (60s TTL)
- Implement comprehensive health information retrieval for all circuit scopes
- Add support for querying circuit states (global, bridge, asset)
- Include recent transitions tracking with configurable limits
- Add manual overrides (whitelisted items) retrieval
- Implement cache invalidation and statistics endpoints
- Create circuit health API routes with full documentation
  - GET /api/v1/circuit-health/health - Full circuit health info
  - GET /api/v1/circuit-health/state - Specific circuit state
  - GET /api/v1/circuit-health/transitions - Recent transitions
  - GET /api/v1/circuit-health/overrides - Manual overrides
  - GET /api/v1/circuit-health/cache/stats - Cache statistics
- Add comprehensive payload documentation and schema definitions

Closes #circuit-health-api
- Create comprehensive test suite for CircuitHealthService
  - Test full circuit health retrieval
  - Test specific circuit state queries
  - Test caching mechanisms
  - Test cache invalidation and statistics
  - Test whitelist operations
  - Test error handling and graceful degradation

- Add detailed API documentation
  - Complete endpoint reference with examples
  - Data model definitions
  - Caching strategy explanation
  - Integration examples and best practices
  - Performance characteristics
  - Error handling documentation

- Document all 5 API endpoints with:
  - Request/response examples
  - Query parameters
  - Status codes
  - Real-world usage patterns
- Fix fastify  registration (remove # suffix) to properly resolve  in route schemas
- Fix circuit health test mocks to correctly simulate chained knex query builders
- Fix accessOverview.routes.ts build error by adding 400 response schema
@drips-wave
Copy link
Copy Markdown

drips-wave Bot commented Jun 2, 2026

@Emeka-12 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

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.

Implement SLA Reporting Service Build Circuit Health API

2 participants