Interactions between communities and their abiotic physical environments form systems known as ecosystems. One of the major phenomena underlying an ecosystem is the flow of energy. Because photosynthesizing organisms trap the energy in an ecosystem, they are producers. Because certain organisms in the community meet their energy needs by feeding on these producers, they are consumers. Producers are autotrophs, while consumers are usually heterotrophs. Primary consumers feed directly on plants, while secondary consumers (carnivores) feed on the animals that eat the plants. The energy flow forms a one-way pattern; the energy is used for metabolic reactions and the remainder is given off as heat.

The linear transfer of food energy from producers to consumers is known as the food chain. Many food chains intertwine in a complex manner to form a food web. Decomposers, the organisms of decay, are found at each level of food chains and food webs. The organisms of decay are usually bacteria and/or fungi.

The food pyramid is a way of expressing the availability of food in an ecosystem at a successive number of trophic levels. The number of producers, always at the base of the pyramid, is high and the number of consumers, at the top of the pyramid, is low. The difference in numbers occurs because only a small percentage of the food energy available at one level can be passed on to the next. The total dry mass of food at each level of the pyramid is called the biomass.

Another phenomenon of an ecosystem is the recycling of elements. Carbon, nitrogen, and phosphorus typify those elements that are recycled. Much of the carbon is recycled in respiration, but more is recycled in decomposition, principally by bacteria and fungi.

Nitrogen, which is vital for the synthesis of proteins and nucleic acids, is released to the atmosphere as waste by bacteria. Nitrogen is brought back into the food chain by nitrogen-fixing bacteria that exist on the roots of plants called legumes (peas, beans, alfalfa, and clover). The bacteria trap the nitrogen, form ammonium ions, and make these ions available to plants for amino-acid synthesis.