This is handled by the inverter and charging modules, some use FPGA chips others use dedicated ASICs, but it doesn’t require anything wild in terms of raw compute power, mostly up to having good algorithms to handle the situations correctly. Nothing more than a modern ICE engine which needs to very precisely manage intake and exhaust cam phasing, ignition timing, intake pressure, and multiple injections per cylinder/cycle along with monitoring a multitude of sensors to keep everything in tolerance. In terms of simplicity, the first automobiles at the turn of the century were electric before the ICE caught on thanks to the advent of the electric starter and limitations in battery technology at the time.
Any chance you are using a Thunderbolt device such as a network adapter or external drives? I had the issue on a NUC 10 where it would randomly drop the TB devices every few weeks and occasionally appear to be frozen. The latest firmware update finally took care of it.