Evolutionary dynamics of microbial communities