I never really understood why, like do we have some special organelle in our cells that convert sunlight to vitamin D or is it something entirely different?
It’s a photochemical reaction.
There’s a chemical in your skin called 7-DHC that’s photochemically reactive to light between the wavelengths of 290 and 320 nm. These wavelengths are part of the sun’s spectrum and what is often referred to as UVB radiation. When 7-DHC reacts with UVB light, the product is dholecalciferol, also known as Vitamin D3, which is then carried to the liver.
When exposed to UV radiation, epidermal cells in the stratum spinosum and stratum basale convert a cholesterol related steroid into Vitamin D3.
The liver converts D3 into an intermediary product used by the kidneys to synthesize a hormone called calcitriol.
Calcitriol is essential for the absorption of Calcium and Phosphorus in the small intestine.
FYI the color of skin is an adaptation to sun exposure in the region of the world your recent ancestors lived. White skin became white in order to absorb more sunlight as we moved north and eventually got trapped during the ice age and the closer your recent ancestors were to the equator the darker the pigmentation in order to protect the skin from the sun. Our hair textures and eye colors adapted the same way. Pretty cool when you think about it and just another why judging some based on skin color is so ridiculous.