A food chain is a food pathway that links a series of organisms with repeated eating and being eaten. The producer is an autotroph which produces its own food by harnessing the Sun's energy. Green plants and some kinds of bacteria are autotrophs. Herbivores and carnivores are heterotrophs and cannot make their own food. Both are consumers.
Herbivores eat producers and are called first order consumers.
The chain ends with an ultimate consumer which has no predator. For all practical purposes, food chains have three to four links and rarely contain more than six. This is because the amount of energy transmitted to the next organism diminishes at each stage. Eventually, there is not enough energy to support another organism. It is worth noting that a food chain is a very simplified and artificial depiction of energy flow in an environment as each organism is represented as having only one kind of prey and one kind of predator.