An ecosystem consists of all the organisms living in a community together with the abiotic factors they interact with. It is structured by many competitive interactions and complex mutualisms between species as well as predator-prey relationships. Ecosystems function through the flow of energy and cycling of materials as organisms capture and transfer carbon, nutrients, and water. Biodiversity allows ecosystems to perform essential functions like photosynthesis and the breakdown of organic matter.