Energy flows in an ecosystem in only one direction. Energy is transferred via food chain, which organisms eat.
Grasses are the primary producers (Autotrophs). They obtain their energy form the sunlight by converting into organic form, starch. These organic substances are then stored in the body parts.
For instance, a grasshopper cannot produce its own energy; hence, it feeds on the grass to get the energy. Grasshopper is then eaten by the frog and frogs are predated by the snakes. The snakes are the food sources of the eagle.
Thus, the energy flow continues from the primary producers to the consumers at all levels.