That's photosynthesis and the byproduct is sugars like glucose which is broken down to release energy, synthesis of cell wall and converted to amino acids.
The plants need essential elements (NPK) too
Nitrate is needed to synthesize proteins and amino acids and most importantly, chlorophyll.
Phosphorus is needed for photosynthesis, cell division, storage of energy and many other activities.
Potassium is needed for protein synthesis, the breakdown of carbohydrates, activation of most enzymes and other processes.
Hope this helps you understand. (Exams coming soon so I hope I've not made any mistakes )