An ecosystem is defined as a natural functional unit comprising living organisms and their non-living environment interacting to form a stable system. The key components of an ecosystem are biotic (living) and abiotic (non-living) factors. Energy from the sun is captured by producers like plants through photosynthesis and transferred through consumers and decomposers in a food chain or food web. Nutrients and matter cycle between biotic and abiotic components. Ecological pyramids illustrate the transfer of energy and matter between trophic levels, with fewer organisms and more biomass at higher levels due to energy losses between levels.