The molecule above is caffeine and the molecule below is theobromine. These molecules give the bitter taste to coffee and tea, in the case of caffeine, and chocoloate, in the case of theobromine. The difference between the two molecules is small. They differ by a single methyl (-CH3) group attached to their six membered rings.
In addition to giving coffee, tea, and chocolate their bitter, and some might say acquired tastes, caffeine and theobromine act as stimulants. Both molecules are similar in shape to part of a molecule known as cyclic adenosine monophosphate, and this confuses the enzyme whose job it is to convert cyclic adenosine monophosphate to a less active form.
The resulting excess of the active form of cyclic adenosine monophosphate leaves the organism with additional stimulation, often manifest in the form of nervous energy.
The physiological result, or buzz, can be quite addictive; a fact not lost on the purveyors of carbonated sugar waters. Hence soft drink companies routinely mix a little caffeine into their products in order to stimulate their customer base and increase their loyalty.
The theobromine in chocolate is probably the chemical origin of chocolate cravings. When such pangs strike, the nervous system is actually craving the stimulation that surplus cyclic adenosine monophosphate provides, and chocolate provides a convenient and familiar route to achieving this surplus.