The role of a species within an ecosystem is called a niche. A niche is all interactions by a species with the living and nonliving things in an environment. It describes an organism's role with the flow of energy through a community. Energy flow refers to how organisms obtain energy—often through what they eat—and how this energy is passed through the ecosystem. A niche also includes an organism's role in interacting with other species in an ecosystem. However, a niche is not the same as a habitat. Habitat describes the physical area where an organism lives, while niche focuses on the organism's role or pattern of living within the habitat. For example, a dung beetle of South Africa specifically lives in and feeds on the dung of wild elephants and buffalo. Dung beetles are entirely dependent on the elephants and buffalo and serve the purpose of aiding in the breakdown of dung to more rapidly add nutrients back into the soil.
As the number of different species increases in a community, biodiversity also increases. However, when biodiversity declines within a community, ecological succession can occur, making an entire community less stable or unable to withstand disturbances that affect its overall structure and function. Ecological succession is a series of progressive changes in species composition that happen after a disturbance in an ecosystem. It happens, for example, when a community undergoes a series of changes that causes organisms to change their environment or causes new species to move into the community. It describes how the structure of species in a community evolves over time. Ecological succession is not sudden; rather, it is a gradual process. One example of an ecological succession is the migration of birds during a natural disaster, such as a hurricane. When a hurricane destroys an entire habitat, it can cause species structure to change as old species leave and new species move into the habitat.