The cacao tree (kah-kow) comes in three varieties, or cultivars, Criollo, Trinitario and Forastero. The pod starts out green in color and while ripening changes to yellow and orange or red, and sometimes even purple. The ripe pod has 20/60 beans or seeds, and one pod is needed to make one 100g bar of chocolate.
After the ripe pod has been cut from the tree, it is opened, the rind is discarded, and the pulp and seeds are piled or laid out on the ground for several days. During this time the pulp liquifies, this is called sweating and a process known as fermentation takes place, which causes the beans to lose bitterness.
This is followed by roasting, which can be done in different ways, for instance by drying the beans in the sun, but also on low heat above a wood fire, solar, etc. Fermentation and roasting have a large influence on the taste of the cocoa. Inside the bean is the cocoa nib, as well as the germ. A winnowing machine or nibber is used to remove the shells of the bean and the germ, leaving only the nib.
In some cases the nibs are dutched which means that alkali (e.g. potassium carbonate) are added: http://en.wikipedia.org/wiki/Dutch_process_chocolate
The purpose is to make the cocoa less acidic and more easily soluble in water. It also makes the flavour more mellow, though some argue that flavors are lost through this process. If cocoa has been treated this way, one can tell by looking whether the ingredients include alkali, and avoid these types.
The next step is to mill the nibs which gives cocoa liquor and get the fat separated from the cacao. This substance consists separating cocoa particles suspended in cocoa butter: http://en.wikipedia.org/wiki/Cocoa_butter
The first to discover the best method to separate the butter fat was Domingo Ghirardelli and what is called Broma process: http://en.wikipedia.org/wiki/Broma_process
If the manufacturer is blending different beans, this is the point when it is done. What is left behind is called a presscake, which is pulverized into cocoa powder.
Chocolate is made by combining cocoa liquor and cocoa butter and adding other ingredients, which can include sugar, milk, emulsifying agent and flavourings. The mixture is then refined by rolling it into a smooth paste. In addition a kneading process known as conching improves the flavour and texture of the chocolate. After several periods of heating and cooling to prevent crystallization of the cocoa butter the mixture is finally poured into moulds and cooled, giving us the ultimate chocolate bar.