My understanding is still very high level, but the UPS would send some type of shutdown command to the computer over USB when it detects a power outage. The computer would be running a daemon that would see the command and initiate the shutdown.
I’m trying to find out if something like this exists in Roon OS.
My (aging) Netgear NAS uses this: Network UPS Tools: HID UPS driver
An APC UPS connects to a USB port on the NAS. Two other NAS boxes checks battery status with the first NAS over the network. (I don’t know how…)