Alkalinity in water is mainly influenced by two main buffering salts which form carbonate ions and bicarbonate ions. The carbonate ion (CO3)2- contains one carbon atom and three oxygen atoms and carries a double negative charge and bicarbonate ion (HCO3)- is a carbonate molecule with one hydrogen atom attached and carrying, a single negative charge. These compounds attract hydrogen ions when the water is acid and release them as the water becomes basic.

The overall effect is that the pH changes much less in well buffered water than in poorly buffered water. Waters with low alkalinity (less than 20 ppm) are poorly buffered against pH change. This means that the addition or removal of a small amount of acid can result in a large pH change. Waters with high alkalinity (more than ppm) are well buffered, and the addition or removal of a small amount of acid has little or no effect on pH.

Understanding the chemistry
If a hydrogen ion is added to the system as a result of respiration, then it will be captured by the carbonate to form bicarbonate. This will prevent the pH from changing (pH is the - log of the concentration of hydrogen ions). If there is a removal of hydrogen ions from the water (from photosynthesis for example) then the bicarbonate(HCO3 -) or carbonic acid (H2 CO3 ) can dissociate to replace the lost hydrogen ions and therefore maintain pH.

Maintaining alkalinity levels in your system
Your system should be maintained to an alkalinity level of at least 30 mg/l although higher levels are desirable.
Alkalinity not only reduces pH fluctuations of the system water but also helps with phytoplankton growth by providing a carbon source (in the form of carbon dioxide) for photosynthesis. Calcium carbonate will not only increase the alkalinity but also the hardness.