# Live Dashboard — Real-Time Event Specification ## Mechanism PHP engine files emit named events to a Node.js process over HTTP after a successful DB commit. Node.js broadcasts the event to all browser tabs in the same company room via Socket.IO. Each dashboard page listens for relevant events and reloads only the sections that changed — without a full page refresh. ``` PHP (engine file) └─ notify_node(event, payload, company_id) // fire-and-forget POST to Node └─ Node.js /emit endpoint └─ io.to('company_{id}').emit(event, payload) └─ Browser (dashboard JS) └─ targeted section reload + flash effect ``` --- ## `notify_node()` (`app/assets/utils/notify_node.php`) Fire-and-forget HTTP POST from PHP to the local Node.js `/emit` endpoint. Called **after** `$pdo->commit()` so the event is never sent for rolled-back transactions. ```php notify_node(string $event, array $payload, int $company_id): void ``` Failure is silently ignored — the DB write is authoritative; the live update is a UX enhancement only. --- ## Socket.IO Room Each company gets its own room: `company_{company_id}`. The browser joins this room on page load via `window._socket` (initialized in `include_ending.php`, always before page `