Long story short: Caffeine is a purine that acts as an adenosine receptor antagonist. Basically, it pretends to be adenosine and binds to adenosine receptors but doesn’t activate them. And blocks adenosine from binding. When adenosine binds, you get sleepy so…
note: this is major oversimplification
here are links to those papers:
Doré AS, Robertson N, Errey JC, Ng I, Hollenstein K, Tehan B, Hurrell E, Bennett K, Congreve M, Magnani F, Tate CG, Weir M, Marshall FH. Structure of the adenosine A(2A) receptor in complex with ZM241385 and the xanthines XAC and caffeine. Structure. 2011 Sep 7;19(9):1283-93. doi: 10.1016/j.str.2011.06.014. PMID: 21885291; PMCID: PMC3732996. https://doi.org/10.1016/j.str.2011.06.014
Xu F, Stevens RC. Trapping small caffeine in a large GPCR pocket. Structure. 2011 Sep 7;19(9):1204-7. doi: 10.1016/j.str.2011.08.007. PMID: 21893281; PMCID: PMC3197023. https://doi.org/10.1016/j.str.2011.08.007
Carpenter B, Lebon G. Human Adenosine A2A Receptor: Molecular Mechanism of Ligand Binding and Activation. Front Pharmacol. 2017 Dec 14;8:898. doi: 10.3389/fphar.2017.00898. PMID: 29311917; PMCID: PMC5736361. https://doi.org/10.3389/fphar.2017.00898