Recovering print after power shutdown

Hello,

I am in dire need of a solution for the print recovery problem.

I have been browsing every available source of information regarding this and similar topics, like:

However, it seems that this is a very niche application and there is no working example, as there are many issues with the implementation.

I have the BTT UPS module, which allows for the printer to be able to operate for several seconds after a power loss and can provide a signal, when the power is out. Additionally, for my particular application, I do not use a heated bed (which would eliminate adhesion issues, as there would be no need to reheat it). Hence I figure that it would be possible to make a save of the current print state whenever the power_out pin is active and toggle a resume print window when the printer is able to run again.

My main issue is the lack of proper understanding of inner workings of Klipper. I would greatly appreciate any feedback on how to implement any of the steps required to reach my goal.

What I have in mind:

Power is gone → Trigger UPS pin → Save position → Raise nozzle, shut-down printer
Power is back → Resume? → Reheat nozzle → Read last coordinates → Continue the print

I am familiar to python, but I am in no way close to understanding all of the Klipper code. If I could obtain any suggestions on how to proceed, I would be very thankful; i.e. which Klipper files are crucial for this functionality, where to add the file creation, etc.