All energy on the planet is governed by the laws of thermodynamics.
The first law states that energy can be transferred but cannot be created nor destroyed. The second law states that while energy is transferred, a portion of it will be lost as heat energy.
In the biological world, all energy begins it’s life in the sun. Solar energy arrives to earth as light in the form of particles of energy known as photons. Some photons are used by plants and are transformed into photochemical energy through a process known as photosynthesis. This energy, combined with carbon from Carbon dioxide in the atmosphere, is stored in complex carbon bonds known as carbohydrates. All life on planet earth is carbon-based and is what is known as “organic.”

The rate at which solar energy is stored in those carbon bonds is known as primary productivity. When we speak about primary productivity, we often refer to net primary productivity. Net primary productivity is measured as the gross primary productivity (the total amount of light energy that the plant converts) minus the amount of energy that the plant uses itself for it’s own survival (known as respiration). Productivity is measured in kilocalories per square metre per year OR as grams per metre squared per year. The amount of energy stored in the plant at any given time is known as the standing crop biomass, measured in grams per metre squared, and so primary productivity can also be measured as the change in standing crop biomass over time.
Primary productivity increases with increasing annual temperature and rainfall, and thus areas around the equator which receive these conditions year-round tend to be more productivity than the regions towards the poles. As such, the most productive terrestrial ecosystem is the tropical rainforest. Other factors which influence productivity are disturbances such as fires and herbivory, the age of the plants, and the amount of nutrients available, especially nitrogen.

In aquatic environments, light and nutrient availability are the main factors influencing primary productivity. The limiting nutrients in these systems are nitrogen, iron, and phosphorus and thus the most productive aquatic ecosystems are ones in which these nutrients are abundant such as shallow coastal waters, coral reefs, and estuaries.
The nutrients (and energy) in a system does not always come from the same system. Energy which is produced within the same system is known as autochthonous, while the energy produced outside a system is known as allochthonous. Allochthonous energy comes in the form of dead organic matter known as detritus.
This leads to two major types of food chains: the grazing food chain (source of energy is plant matter) and the detrital food chain (source of energy is detritus).
When an organism eats something, whether that be detritus, a plant, or another living organism, some of the energy is used for the processes of survival for the organism and to generate heat. Apart from waste products, the remainder of the energy is used for growth and is known as secondary production.

The efficiency of this process can be quantified through a number of different metrics such as consumption efficiency (the proportion of available energy being consumed), assimilation efficiency (the portion of energy that is used), and production efficiency (the portion of used energy that is stored leading to growth). Only 10% of the energy stored in one level is converted to biomass (production efficiency) at the next level, creating a pyramid amongst terrestrial communities where the plants make up the largest part of the base and herbivores and carnivores make up sequentially smaller portion of the pyramid. This pyramid is reversed in aquatic systems, as due to the short lifespans and high reproduction of the phytoplankton, the number of phytoplankton in the water at any given time is much lower than the herbivores and carnivores giving a form of inverted pyramid. It is also important to note that due to this rapid turnover of phytoplankton, energy is stored for less time than in land-based ecosystems, where energy is stored for longer periods of time (ex. trees).
Lastly, there are two main types of ecosystem control within these communities: Bottom-up, where plant production limits the number of herbivores and thus carnivores, and Top-down, where the number of carnivores limit the number of herbivores and thus controls the total amount of plants in the system.