A journaling filesystem is less prone to corruption, so ext4 is used, still it is not 100% safe. By default in raspbian you have option flags in fstab, that upon power up, it does a filsystem check and repairs corrupted SD card.
Well there are lot of UPS boards, but many of them are useless, they just invoke
sudo shutdown -h nowscript at detected power outage and the capacitors supply the board for few seconds. But if you reconnect the power before the capacitors are drained out, then the board won't start again automatically.
A good UPS has to have an additional MCU that handles the correct sequence. For example the Beaglebone has an standalone PMIC, but they never thought about to use it correctly. Most of these boards are stamped in millions copies, but they lack of very basic functionality, shutdown sequence.