Exercise and your body’s normal metabolism uses energy. ATP (Adenosine triphosphate) is energy currency — if you will — used by the body to carry out those functions. Adenosine is a byproduct that signals to the body that energy is being depleted and it would probably be a good idea to rest and wind down. It signals this to the brain via adenosine receptors A1 — more directly associated with fatigue and A2a — more associated with the mood related to fatigue). Caffeine stops adenosine from telling the brain you’re tired when it blocks A1, and A2a blockade causes a release of dopamine which makes you feel good.
These effects are really pronounced in someone who drinks coffee rarely or who has just begun to drink coffee. They are diminished over time when someone drinks coffee regularly. This is because to combat the effect of caffeine blocking the A1 and A2a receptors, the brain produces more of both. This is called upregulation. Because the same amount of caffeine can only block the same amount of receptors, adenosine can signal tiredness more effectively. This is why coffee drinkers find they may need to drink more to get the same effect. This is called tolerance.
**Fun fact, caffeine causes vasoconstriction — the tightening of blood vessels. When one stops drinking coffee, their blood vessels vaso-dilate or widen. It is believed vasodilation of the blood vessels in the brain are responsible for headaches.