You need to come up with all the parts here .
Power sensing
Phase sensing
Then line switching
Offline power
On line power
Could use a phase detector for phase sensing but what of the power, do i need to sense both the voltage and current for the load? Didn't understand the offline and online power lines, please explain more.
I am now basing on the USB Bit Whacker-18F2553 that you posted.
Thanks