The structure of ATP can be seen in the adjoining figure. The molecular formula is C10H16N5O13P3 and the various elements can be seen in the image. The wavy red lines represent the high energy bonds which release energy during hydrolysis.

click to enlarge
Before ATP can release energy it has to be produced. ATP production is a chemical process formed from a reaction between adenosine diphosphate and inorganic phosphate. The result is the formation of ATP and water. The reaction itself requires significant amounts of energy (which is of the order of 7.3 kcal/mole) and the process takes place through various modes such as glycolysis, photosynthesis and cellular respiration.
When the reaction takes place the other way round during metabolic processes, the same amount of energy is released and hence ATP acts as the source of energy. The reaction in this case is given by
ATP + HO → ADP + P + Free Energy