You can design from scratch but there are much easier solutions. For control applications I suggest using MQTT because it is a standard and available on most platforms, including Android.
Add an MQTTT (pubsub) library to your ESP program and an MQTT client on your Android device, they will talk to each other over WiFi. I use "EspMQTTClient" on ESP8266 and ESP32 devices and on my Android phone and tablet I use "IoT MQTT Panel Pro". With those I can control many devices across several WiFi links and have graphical switches, sliders, meters and other widgets to make it look nice. I also use a Raspberry Pi as the MQTT broker and it also runs "Node Red", giving me mobile access though a cheap 4G dongle and runs a webcam at the same time.
Brian.