Can i exchange my arduino nano for an atmega328p-pu in my project?

Im currently trying to make a smart light switcher that is attached in front of my rooms light switch. It basically mostly consists of a servo (turn on or off the lights), a button (to turn the servo manually), an esp8266 esp-01 module (to be able to use with a google home) and my arduino nano. I really need to make it as small as posible and i also want to keep my only arduino not attached to the wall. Would it work if i use an atmega328p or like an attiny84a to replace the arduino?

Im not finished with connecting the esp-01 to the arduino but i was thinking of using the arduino's 3.3v output pin. Would i need extra components to run the microcontroller on its own?

Im really new to arduino and im trying to learn the most I can and to try to make my little project as good as i can. (Sorry for my english its not my first language).

Would really like some help please, thank you!

You can , in principle, replace an Arduino Nano with a raw ATmega328P chip (plus maybe a crystal and 2 capacitors). You'd need, though, a USBTTL device to program it (which is already integrated with the Nano).

You may find that if you use a Wemos D1 Mini (instead of an ESP-01) that you can eliminate the ATmega328P completely.

If you have an ESP8266 there is no need to add an Arduino/ ATmega328. Your only concern is interfacing the output of the ESP to your servo (and button) - a 74HCT14 or 74HC04 will do that nicely.

As an aside the SONOS devices are based on the 8266 and there are hacks about for reprogramming them that Mr Google will find .
There is the advantage that all the hardware is built in for psu etc with these and operate your light electronically

@marcelomm, please do not cross-post. Threads merged.