Solar panels are made of a collection of solar cells, which are typically made of silicon. When sunlight hits the solar cells, it stimulates the movement of electrons in the silicon creating a flow of electric current. This process is called the photovoltaic effect. The electricity produced by the solar panels is DC (Direct Current), while our homes and business run on AC (Alternating Current). Hence, the need for an inverter, a device which converts the DC electricity from the solar panels into AC electricity. From the inverter, the AC electricity will then travel to the meter box from where it gets distributed to the different appliances and power points.
Excess power that is not used by your home will either be fed back to the grid or if you have a solar battery it can be stored to use later when the panels are not producing enough power.
Electricity will be drawn back from the grid when you need more power than you produce.
This process of sending excess electricity back to the grid and drawing from the grid is monitored through a system called net metering and your electricity provider will either charge you for the electricity used or pay you a feed-in tariff for the electricity fed back to the grid.