The flow of energy through the food web begins with the sun, which provides energy for the primary producers, such as plants, to undergo photosynthesis. The primary consumers, such as herbivores, eat the plants, and the energy is transferred to them. The secondary consumers, such as carnivores, eat the herbivores, and the energy is transferred to them. The tertiary consumers, such as apex predators, eat the carnivores, and the energy is transferred to them. Decomposers, such as bacteria and fungi, break down dead organisms and return nutrients to the soil, which can then be used by the primary producers. The energy flow through the food web is unidirectional, with energy being lost as heat at each level.