An ecosystem's function is broad, vast and completely dynamic in nature. Through the interaction of living organisms, they are organised into trophic levels, food chains and food webs. Energy flow and nutrient flow are basically responsible for how an ecosystem functions as it helps in distribution and circulation of the organic and inorganic matter within an ecosystem.
Through various levels in an ecosystem energy flows from one level to another (unidirectionally) in a hierarchical order. These levels are called trophic levels. Energy flows from producers to subsequent trophic levels. This energy always flows from lower (producer) to higher (herbivore, carnivore etc.) trophic level. It never flows in the reverse direction, i.e. from carnivores to herbivores or producers.
The chain of transformation of energy from one group of organisms to another through various trophic levels is called a Food chain.
A system of interlocking and interdependent food chains is called a Food web.
A food chain is about who eats whom, whereas a food web is all of the food chains in an ecosystem.