How it happens
The plant needs sun, water, and Co2 for photosynthesis. Plant starts absorbing sun energy in it's leaves, water in it's roots and Co2 in it's stomata.
Now photosynthesis will begin. It converts the sun energy and Co2 into glucose sugar and the waste product is oxygen.
Using the Energy
Oxygen is released through the stomata and glucose is given to the rest of the plant through the phloem to the rest of the plant so the process can restart.