In plants, these energy factories are called chloroplasts. They collect energy from the sun and use carbon dioxide and water in the process called photosynthesis to produce sugars.
Links
[1] https://hootsgo.org/?q=node/6464
[2] http://hyperphysics.phy-astr.gsu.edu/hbase/biology/enercyc.html