The transfer of energy through an ecosystem, typically starting from the sun and moving through producers, consumers, and decomposers.