Last October, I attended an event sponsored by the American Chemical Society at the Institute of Culinary Education. The topic was "Chemistry of Chocolate."
Harold McGee, author of On Food and Cooking: The Science and Lore of the Kitchen, lectured on the process of turning a cacao pod into edible chocolate.
Within the cacao pod are the beans surrounded by a sweet pulp. What happens is that these pods are broken open and thrown into a pit where the beans allowed to sit in the pulp as it naturally ferments.
The first photo shows 4 cacao beans. The two on the left are covered with mold. As the pulp of the cacao seed pod surrounding the beans ferments and produces acids that seep into the beans and change it chemically.
The ones on the right have been dried and are now ready to be processed into chocolate.
The next photo shows a cross section of the beans. After drying (right), you can see that the material in the bean is more homogeneous and compact.
Then, according to the Wikipedia:
After fermentation, the beans are dried, cleaned, and roasted, and the shell is removed to produce cacao nibs. The nibs are then ground and liquified, resulting in pure chocolate in fluid form: chocolate liquor. The liquor can be further processed into two components: cocoa solids and cocoa butter.