A food chain or a food web is a way to trace energy through an ecosystem. For most ecosystems (deep ocean vents being the exception), sunlight is the source of energy. The sunlight is captured through photosynthesis in the cells of plants, which are primary producers. The plants are eaten by herbivores, which are primary consumers (examples: insects, deer, squirrels). The primary consumers are eaten by secondary consumers (insect-eating birds, weasels, bobcats). Tertiary consumers eat secondary consumers; these are usually the top carnivores, such as hawks and wolves.Saprobes and detritivores eat dead organic materials and recycle nutrients back into the soil - these would be things like worms, maggots, and fungi.
At each step along the way some of the energy is lost as heat, so the sun's input is needed to keep the web supplied with new energy all the time.