There are diferent resources for creating components for ESPHome.
ESPhome architecture documentation provides a high level description on how to create a simple component. It also links to examples in a repository.
The examples provided describe simple components and some complex ones, using inheritance, for example to create a binary_output component out of a binary_sensor and an output component, or a text_sensor derivative out of a text_sensor.
Video tutorials
I will not go into them, I prefer blog tutorials
Blog tutorials
This tutorial is a comprehensive and informative resource, accompanied by a helpful video that provides additional insights and visual guidance.
This tutorial give some insights on how to break your component code in different pieces to avoid creating a huge __init__.py file.