To synchronize local on-premise databases with a centralized cloud-based real-time system.
Healthcare units across the network needed to synchronize local on-premise databases with a centralized cloud-based real-time system.
Healthcare units across the network needed to synchronize local on-premise databases with a centralized cloud-based real-time system. However, challenges such as intermittent internet connectivity, firewall restrictions, and the need for secure, continuous WebSocket communication made direct cloud connections unreliable.
The core problem was ensuring real-time synchronization of appointments, registrations, payments, and patient updates from over 500+ healthcare units, while maintaining data integrity, security, and connection resilience.
The goal was to design a lightweight, resilient local service capable of:
Bridging the on-prem database with the WebSocket Gateway hosted in the cloud.
Maintaining persistent and self-healing WebSocket connections to ensure uninterrupted real-time data exchange.
Enabling secure and standardized communication across heterogeneous environments.
This service would act as the foundation of the platform’s real-time capabilities, ensuring clinics could remain connected even in constrained or fluctuating network environments.
Each healthcare unit runs a Local Windows Service that establishes a secure WebSocket connection with the cloud WebSocket Gateway.
The service continuously performs ping-pong heartbeat events to maintain live connectivity.
When an event (registration, appointment, or payment) occurs locally, the service sends it via WebSocket to the cloud in real time.
Incoming cloud updates are reflected back into the local SQL Server database.
Logs, errors, and connection health states are continuously monitored and auto-recovered.
(Visualized in the Context Diagram)
Local Database (SQL Server): Source of truth for clinic-level transactions.
Local Service (C# .NET): Engine managing data exchange and maintaining persistent WS connections.
WebSocket Gateway (Node.js): Central relay distributing real-time updates to and from all clinics.
API Bridge: Facilitates coordination with the main Web API Gateway when REST-based operations are required.
Logging & Monitoring Layer: Captures connection lifecycle events (connect, close, error, unexpected shutdown) with auto-recovery logic.
(Visualized in the Container Diagram)
Connection Layer:
Initiates WebSocket connection to the central gateway with JWT-based authentication and SSL (RSA private key + certificate).
Maintains active sessions through ping-pong and heartbeat validation.
Schema Layer:
Defines a generalized request/response schema, supporting scalable message types without structural changes.
Security Layer:
Utilizes crypto-js for encryption/decryption of sensitive payloads.
Employs jsonwebtoken for identity validation.
Logging & Recovery Layer:
Implements daily rotating logs, categorized by connection events (connect, message, error, unexpected close).
Automatically removes stale or disconnected clients from the connection pool.
(Visualized in the Component Diagram)
Language Selection:
Implemented in C# (.NET Windows Service) due to the clinic’s existing infrastructure (SQL Server, .NET Desktop Apps), enabling seamless local integration.
Cross-Technology Integration:
Despite the backend using Node.js WebSocket Server, the hybrid model was chosen for compatibility, cost-effectiveness, and maintainability.
Security Architecture:
Enforced JWT-based authentication and RSA + SSL encryption for all data exchanges.
Scalability Approach:
Introduced generalized JSON schemas allowing future event types without code changes.
Reliability:
Built-in auto-reconnect and connection health monitoring mechanisms to handle network drops or firewall interruptions.
Enabled 500+ remote healthcare units to stay connected with real-time synchronization.
Reduced data sync failures by over 90% through robust auto-reconnect and monitoring.
Improved security posture with end-to-end encryption and JWT authentication.
Supported seamless integration of VoIP, appointment booking, and payment modules without architectural changes.
Proved to be a future-proof design, sustaining long-term scalability and maintainability across mixed tech stacks.
Established a key architectural foundation that now underpins all real-time operations within the healthcare platform ecosystem.