Melatonin is a hormone found in animals, plants, and microbes. In animals, levels of melatonin have a daily cycle. It drives the circadian rhythms of several biological functions.
Melatonin is produced in the pineal gland which is outside of the blood–brain barrier. It acts as a hormone, and is released into the blood.
Melatonin acts on melatonin receptors. It also acts directly because it is a powerful antioxidant, which protects DNA.