An ecosystem is defined as a system including living organisms and their physical environment interacting as a unit. It consists of biotic components like organisms and dead organic matter, abiotic components like soil, water and atmosphere, and the interactions between them. Energy from the sun flows through ecosystems, with organisms playing different roles as producers, consumers or decomposers. Ecosystems are classified as terrestrial like forests and grasslands, or aquatic like ponds and oceans, and perform functions like regulating processes, supporting life, and maintaining nutrient cycles and energy flow between trophic levels.