Hello,
First of all, which firmware are you going to use for the ESP8266?
Then what kind of protocol are you going to use to communicate with the esp8266 (mqtt, http, etc)?
Which kind of relay do you have? Something like this?
https://community.home-assistant.io/t/uk-wall-switch-options-photos-included/29690/4?u=garvarma
And of course, are you going to use home assistant? or your own one?
After reply this questions, then maybe we can help you more.