The process consists of several steps.

An excerpt from the article 16 facts about Chocolate
The first stage takes place in plantations, where the fruit, cut in half, ferments in special tanks. The process lasts three to six days, during which the sugars in the flesh surrounding the grains are broken down into alcohol and then acetic acid. At the end of this stage, the beans contain about 60% of water, so they are dried.