I think that the sun provides the primary source of energy in ecosystems, and energy and matter travel through ecosystems in a unidirectional energy flow and a cyclical nutrient cycling process. These processes contribute to the functioning and stability of ecosystems.
Sun is the only source of energy for all ecosystems on earth. All consumers depend directly or indirectly on green plants for nutrition and solar energy is trapped in green plants. Source of energy in an ecosystem is sun. The solar energy is trapped by green plants and converted into biologically useful form i.e., carbohydrates. The fundamental source of energy in almost all ecosystems is radiant energy from the Sun. The energy of sunlight is used by the ecosystem's autotrophic, or self-sustaining, organisms. Biotic factors include plants, animals, and other organisms. Abiotic factors include rocks, temperature, and humidity. Every factor in an ecosystem depends on every other factor, either directly or indirectly. A change in the temperature of an ecosystem will often affect what plants will grow there, for instance. Energy enters all ecosystems from the sun or from inorganic chemicals. The energy then flows through ecosystems from producers, who can use inorganic forms of energy, to consumers, who can obtain energy only from organic compounds in other living things. Dead producers and consumers and their waste products provide matter and energy to decomposers. Decomposers transform matter back into inorganic forms that can be recycled within the ecosystem. So, the energy that enters an ecosystem as sunlight eventually flows out of the ecosystem in the form of heat.The energy flow is unidirectional and linear. It means energy can flow in a fixed direction, from lower levels to higher levels. Unlike the one-way flow of energy, matter is recycled within and between ecosystems. Unlike the one-way flow of energy, matter is recycled within and between ecosystems. Most ecosystems rely on a supply of energy from sunlight. Light energy is converted to chemical energy in carbon compounds by photosynthesis. Chemical energy in carbon compounds flows through food chains by means of feeding. Ultimately, sunlight is the key source of energy that supports almost all life and ecosystems. Sunlight is used by photoautotrophs to combine carbon dioxide and water into simple organic molecules through the metabolic process of photosynthesis. As energy moves through an ecosystem, it changes form, but no new energy is created. Similarly, as matter cycles within an ecosystem, atoms are rearranged into various molecules, but no new matter is created. The Sun is the major source of energy for organisms and the ecosystems of which they are a part. Producers such as plants, algae, and cyanobacteria use the energy from sunlight to make organic matter from carbon dioxide and water. This establishes the beginning of energy flow through almost all food webs.