# WebSocket Server

This folder documents the standalone server that relays real-time updates over WebSockets.

Clients connect and send a `subscribe` payload describing the tenant, branches or users they want to receive messages for. Messages published on Redis with matching routing fields are forwarded to all subscribed clients.

When a client sends a `push` message, the server forwards it to the PHP API and replies with a `pushResult` message containing the API response. The acknowledgement is also translated into an `updates` payload and broadcast to all other subscribers who match the sender's subscription.

Set the `WS_DEBUG` environment variable to `true` to write detailed logs to `logs/websocket_debug.log`.
