The structure of ATP (adenosine triphosphate) and some basic info about it can be found at
http://en.wikipedia.org/wiki/Adenosine_triphosphateBasically, ATP is a nucleotide consisting of a monosaccharide (ribose), an aromatic amine (adenine), and three phosphate groups.
Most of the time ATP is made from ADP (adenosine diphosphate) by transfer of a phosphate group to ATP. This can be achieved by two means substrate-level phosphorylation (the phosphate is transfered from an activated substrate to ADP) or oxidative phsophorylation (catalyzed by the enzyme ATP synthase, located in the mitochondrial inner membrane). ATP is not a byproduct of the reaction between sugar and oxygen, per se, but the cell uses the energy derived from the oxidation of nutrients such as carbohydrates, fats, and proteins to drive the production of ATP.
Of course, you may be asking where the ADP comes from. The ribose is produced through the pentose phoshphate pathway and the pyrimidine ring of the adenine is synthesized from amino acids. The biosynthetic pathways to form nucleotides (such as ATP) are very complicated (~13 reactions) and can probably be found on wikipedia or in any biochemistry text.