An ecosystem is the complex of living organisms, their physical environment, and all their interrelationships in a particular unit of space.

The principles underlying the study of ecosystems are based on the view that all the elements of a life-supporting environment of any size, whether natural or man-made, are parts of an integral network in which each element interacts directly or indirectly with all others and affects the function of the whole. All ecosystems are contained within the largest of them, the ecosphere, which encompasses the entire physical Earth (geosphere) and all of its biological components (biosphere).

An ecosystem can be categorized into its abiotic constituents, including minerals, climate, soil, water, sunlight, and all other nonliving elements, and its biotic constituents, consisting of all its living members. Linking these constituents together are two major forces: the flow of energy through the ecosystem, and the cycling of nutrients within the ecosystem.

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. Consisting largely of green vegetation, these organisms are capable of photosynthesis--i.e., they can use the energy of sunlight to convert carbon dioxide and water into simple, energy-rich carbohydrates. The autotrophs use the energy stored within the simple carbohydrates to produce the more complex organic compounds, such as proteins, lipids, and starches, that maintain the organisms\' life processes. The autotrophic segment of the ecosystem is commonly referred to as the producer level.

Organic matter generated by autotrophs directly or indirectly sustains heterotrophic organisms. Heterotrophs are the consumers of the ecosystem; they cannot make their own food. They use, rearrange, and ultimately decompose the complex organic materials built up by the autotrophs. All animals and fungi are heterotrophs, as are most bacteria and many other microorganisms.

Together, the autotrophs and heterotrophs form various trophic (feeding) levels in the ecosystem: the producer level, composed of those organisms that make their own food; the primary-consumer level, composed of those organisms that feed on producers; the secondary-consumer level, composed of those organisms that feed on primary consumers; and so on. The movement of organic matter and energy from the producer level through various consumer levels makes up a food chain. For example, a typical food chain in a grassland might be grass (producer) mouse (primary consumer) snake (secondary consumer) hawk (tertiary consumer). Actually, in many cases the food chains of the ecosystem overlap and interconnect, forming what ecologists call a food web. The final link in all food chains is made up of decomposers, those heterotrophs that break down dead organisms and organic wastes. A food chain in which the primary consumer feeds on living plants is called a grazing pathway; that in which the primary consumer feeds on dead plant matter is known as a detritus pathway. Both pathways are important in accounting for the energy budget of the ecosystem.

As energy moves through the ecosystem, much of it is lost at each trophic level. For example, only about 10 percent of the energy stored in grass is incorporated into the body of a mouse that eats the grass. The remaining 90 percent is stored in compounds that cannot be broken down by the mouse or is lost as heat during the mouse\'s metabolic processes. Energy losses of similar magnitude occur at every level of the food chain; consequently, few food chains extend beyond five members (from producer through decomposer), because the energy available at higher trophic levels is too small to support further consumers.

The flow of energy through the ecosystem drives the movement of nutrients within the ecosystem. Nutrients are chemical elements and compounds necessary to living organisms. Unlike energy, which is continuously lost from the ecosystem, nutrients are cycled through the ecosystem, oscillating between the biotic and abiotic components in what are called biogeochemical cycles. Major biogeochemical cycles include the water cycle, carbon cycle, oxygen cycle, nitrogen cycle, phosphorus cycle, sulfur cycle, and calcium cycle. Decomposers play a key role in many of these cycles, returning nutrients to the soil, water, or air, where they can again be used by the biotic constituents of the ecosystem.

The orderly replacement of one ecosystem by another is a process known as ecosystem development, or