The synthesis of carbohydrate chains, or glycosylation, occurs in the endoplasmic reticulum and Golgi apparatus. It involves the sequential addition of sugar residues to proteins or lipids, mediated by specific enzymes called glycosyltransferases. The precise structure of the carbohydrate chain is determined by the types of sugars added and the enzymes involved.