Photosynthesis is the process by which plants, algae, and some bacteria convert light energy (typically sunlight) into chemical energy stored in carbohydrates, using carbon dioxide and water as raw materials and releasing oxygen as a by-product. The reaction occurs in chloroplasts and proceeds through the light-dependent reactions (in thylakoid membranes) and the Calvin cycle (in the stroma). Photosynthesis is the foundation of nearly all life on Earth, producing the atmospheric oxygen that aerobic organisms depend on.