Ecosystems consist of living organisms interacting with each other and their non-living environment. Energy from the sun flows through producers, such as plants, which are eaten by consumers and decomposed by detritivores, recycling nutrients and matter back into the environment. Populations of different species living together form communities within ecosystems.