Location: Lagos, Nigeria.
Nothing works perfectly.
Some things work better than others.
If you are serious you want a UPS or equivalent.
A transformer supply is less likely to die than a SMPS
If you want load "hold up" you want energy storage. This is usually in capacitors in a SMPS. Storing energy in capacitors for more than a brief blip requires vast capacitance - not realistically done.
Using an isolation transformer as a surge and spike suppressor has some merit.
Spike removal can use MOVs, gas discharge tubes, zeners and similar. Gas discharge tubes are the "gold standard".
Batteries are used to get holdup from tenths of a second through minutes + with a smps.
If budget is low a pretending "Ward Leonard machine" is a possibility.
WL is an AC motor driving a DC generator but you could drive an AC alternator with an AC motor. Hold up time depends on flywheel size.
You MAY be able to get an OK result with an unloaded induction motor running on the circuit storing energy mechanically and acting as an energy store. . More information is require in on power level required
This page
may prove useful - he is using a petrol motor to power an alternator which is based on an induction motor but the principle is the same.
Mechanical storage in a flywheel or similar has the advantage of possibly being able to use surplus parts. How well that applies in Lagos I don't know.
Overvoltage isn't so much the issue as over-current. The host supplies the voltage and you can reasonably assume that it's not suddenly going to supply more than 5V.
The two most important failure modes to protect against are:
if your device is connected to anything else with a power supply of its own, that supply must not feed back into the USB port.
if there is a short circuit or overcurrent in the device, it must not draw more power than is reasonable for a USB device. (normally 500mA, although technically you have to negotiate the use of more than 100mA, and some standalone chargers may give you up to 2A)
A standard means of protecting against overcurrent damage is a polyfuse (resettable fuse). Current limiting in normal use can be done by one of many power controller ICs, which are also useful for supplying other voltages, charging batteries, identifying when a high-current charger is plugged in, etc.
Best Answer
The transformer inductance and load capacitance are both dependent on the frequency so linear supplies using 50 Hz must be 1000 x bigger than 50kHz SMPS using small round ferrite inductors.