How is a food chain related to energy flow within an ecosystem?
A food chain is a linear way of detailing what eats what essentially. For example, a carnivore consumes a herbivore, that herbivore consumed some sort of green plant, and that green plant used light as an energy source. The green plant would be called a primary producer and that herbivore a primary consumer. The carnivore that consumed the primary consumer would be called a secondary consumer. Decomposers, for example bacteria and fungi, break down dead organisms and return that energy to the environment.
Through each of these stages, energy is lost to the environment. The carnivore does not obtain 100% of the energy available from the herbivore. A significant portion of energy is lost.
Ecosystems are communities of living organisms. Thus, within an ecosystem there will be many food chains, and energy will constantly be moving from one form to another.
Here's a link to learn more about energy and food chains.
Detailed, with good pictures on this page: https://www.boundless.com/biology/textbooks/boundless-biology-textbook/ecosystems-46/ecology-of-ecosystems-256/food-chains-and-food-webs-948-12208/