Alkaloids are compounds containing nitrogen in a heterocyclic ring that are common to about 15 to 20% of all vascular plants. They are synthesized by plants from amino acids.
The amino acids are decarboxylated to amines and then react with amine oxides to form aldehydes. Mannich-type condensation of the aldehyde and amine groups creates their characteristic heterocyclic ring.
Alkaloids are subclassified on the basis of the chemical type of their nitrogen containing ring. Alkaloids are formed as metabolic by-products. However, their characteristic bitter taste and accompanying toxicity generally help to repel insects and herbivores. Complicated ecological interrelationships have developed between several insects and alkaloids. For example, the consumption of specific pyrrolizidine alkaloids is necessary for some danoid butterflies to synthsize their pheromones.