Cannabinoids and their analogues interest researchers for their potential medical applications. However, the scheduling of cannabis and its structural complexity pose limitations for chemical synthesis. Understanding the biosynthesis of cannabinoids (how they are produced in living tissues) has allowed scientists to target and engineer cannabinoids synthetically, such as from yeast.
To start, three enzymes are involved in the biosynthesis of three major cannabinoids, namely: cannabidiolic acid synthase (CBDAS), cannabichromenic acid synthase (CBCAS), and tetrahydrocannabinolic acid synthase (THCAS).  These enzymes convert cannabigerolic acid (CBGA) into the acidic forms of the major phytocannabinoids: CBDA, CBCA, and THCA.  However, the chemical process is not as simple as it may sound.
Most cannabinoids are synthesized from a process that converts olivetolic acid and geranyl pyrophosphate (GPP) to cannabigerolic acid (CBGA). 
The synthesis of olivetolic acid has not been fully determined. It may be formed through the condensation of five molecules of malonyl-CoA with acetyl-CoA.  A more recently elucidated route is the condensation of hexanoyl-CoA with three molecules of malonyl-CoA for 3,5,7-trioxododecanoyl-CoA. This is subsequently aromatized by olivetolic acid cyclase and olivetol/tetraketide synthase into olivetolic acid. [1,3,4] Tahir et al  explain that “olivetol synthase and olivetolic acid cyclase cooperate to deliver the key intermediate.”
Reprinted from: Tahir MN, et al. The biosynthesis of the cannabinoids. J Cannabis Res. 2021;3(7). License: CC BY 4.0
GPP synthase catalyzes the synthesis of GPP from dimethylallyl pyrophosphate and isopentenyl pyrophosphate.  Researchers found a particular enzyme in hemp, labeled geranyl pyrophosphate:olivetolate geranyl transferase (GOT), that catalyzes formation of CBGA. 
The next stage is the cyclization of CBGA to produce acidic cannabinoids THCA, CBDA, and CBCA. This occurs via synthase enzymes specific to each cannabinoid (as mentioned). The final step that gives rise to active/neutral phytocannabinoids is decarboxylation. This non-enzymatic process happens spontaneously during storage or through heating. 
The synthesis of cannabinoids is the subject of great debate as the exact mechanisms are not fully understood (e.g., formation of olivetolic acid). However, the pathways mentioned above provide significant insight. Modifying the genes of yeast to produce GPP and olivetolic acid, for example, has allowed researchers to produce cannabinoids from these organisms.
1- Tahir MN, et al. The biosynthesis of the cannabinoids. J Cannabis Res. 2021;3(7). [Impact Factor: n/a; Cited by: n/a]
2- Fellermeier M, et al. Biosynthesis of cannabinoids. Incorporation experiments with (13)C-labeled glucoses. European Journal of Biochemistry. 2001;268:1596-1604. https://doi.org/10.1046/j.1432-1327.2001.02030.x. [Impact Factor: 4.392; Cited by: 113 (Semantic Scholar)]
3- Taura F, et al. Characterization of olivetol synthase, a polyketide synthase putatively involved in cannabinoid biosynthetic pathway. FEBS letters. 2009;583(12):2061–2066. [Impact Factor: 3.057; Cited by: 78 (Semantic Scholar)]
4- Gagne SJ, et al. Identification of olivetolic acid cyclase from Cannabis sativa reveals a unique catalytic route to plant polyketides. Proceedings of the National Academy of Sciences of the United States of America. 2012;109(31):12811–12816. [Impact Factor: 9.412; Cited by: 146 (Semantic Scholar)]
5- Fellermeier M, Zenk MH. Prenylation of olivetolate by a hemp transferase yields cannabigerolic acid, the precursor of tetrahydrocannabinol. FEBS Letters. 1998;427(2):283-285. doi:10.1016/S0014-5793(98)00450-5.[Journal Impact Factor: 3.057; Cited by 138 (Semantic Scholar)]