Relay and wifi module
Since there's enough &quot;smart&quot; switches that do that, the answer is clearly that it's possible. That answers your question, but let's be helpful instead of just correct:
You still shouldn't do that: when you use an external power supply, someone who knows electronics makes sure you're not getting killed. Building a 230 V switch-mode power supply isn't trivial, and so you'd either buying a industrial module (more expensive than a whole commercially available smart switch, or an external 5V supply) or building something that's dangerous if you have no education on building safe circuitry and a good understanding of electronics.
When you build this into your own design, it's your fault if you get electrocuted or your house burns down in your sleep. As a beginner's project maybe do something that doesn't involve 230 V; you're not building this for any productive usage, anyways. (if you plan to do exactly that: don't. A commercially available device would be much much cheaper due to the economics of scale than an equally safe device that any of us could build ourselves.)