Follow the official installation guide.
Config examples provided by community https://www.home-assistant.io/examples/#example-configurationyaml
Disclaimer: this is a hobby projects and schematics could be simplified by using different parts. I've used what I had, and for learning purposes.
Home page https://esphome.io/
Location of configuration files within host machine:
/usr/share/hassio/homeassistant/esphome