There is a big machine in the back called a carbonator that injects carbon dioxide from a large tank into the available tap water (usually run through a series of charcoal and particulate filters to remove chlorine and other little nasties in the tap water). It also chills the water. I believe the chilling is necessary for proper absorption of the carbon-dioxide.
The carbonator also has hookups for syrup, which is stored either in 5 gallon keg style tanks or 2-3 gallon "bag-in-boxes." There are separate tubes/pipes/lines/hoses (whatever you want to call them) for the carbonated water and for each different flavor soda that run from the back room to the fountain heads. The syrup is delivered via regulated pressure from the CO2 tank, and the carbonated water is either delivered via tap water pressure, or it?s pumped (I?m not exactly sure which.)
When you press the button for your favorite soda, solenoid valves open for both the carbonated water and the syrup and they mix right inside the plastic nozzle just before it falls into your cup.
Proper calibration of the water to syrup ratio is important, as is frequent cleaning and sanitation of the pop nozzles. A lot of places probably neglect both of these procedures, and the result is nasty tasting soda.
Calibration should be rechecked at least a few times per year, preferably monthly. Calibration is easily checked with a calibration nozzle and cup. This nozzle separates the water and the syrup into different streams, and a specially made divided cup catches both streams simultaneously. If the level of the syrup and the water come out the same, then that flavor is properly calibrated. If not, then an adjusting screw on the solenoid valve is turned to change the syrup:water ratio and the calibration is tested again.
You?d be surprised how much black nasty stuff grows in the nozzles of sugar pops (nothing grows in the Diet Coke nozzle ). They need to be cleaned and soaked in sanitizer (chlorine) water at least weekly, preferably daily.
There are also pre-mix dispensers that merely cool pre-made pop that?s stored in 5 gallon tanks, but these are only used in low volume situations or where greater portability is required. Any restaurant or convenience store would have a post-mix system like I described above.