help: how to make my project always on?

My question is, how can I make Arduino always running? What I want is its main power source is AC supply, and in our country, AC always fluctuates or have some power outages, so I want to solve it by switching the power to DC ( with a battery pack charged with solar ) instantly if the AC is off and switch back again to AC when it is back on.

Because I dont want to stop its sensor monitoring

Moved your topic to it's current location as it is more suitable.

Could you take a few moments to Learn How To Use The Forum.
Other general help and troubleshooting advice can be found here.
It will help you get the best out of the forum in the future.

What is the length of these power outages ?

If a Lithium battery power source is connected to a charging source, you would connect the battery to the Arduino.

You can also use an AC/DC power supply and battery connected through isolation diodes connect to the Arduino input power jack.

You could connect an AC to 5v converter to the USB jack and a battery (being charged) to the power jack.

Battery supplied by a mains charger works for me.

Size the battery to cover outages with ease.