Materials and methods Variability in environmental conditions and agricultural practices frequently influence the quality of the traditional Chinese medicine, ChaiHu. In this study, we utilized 16S rRNA sequencing and UPLC-MS based metabolomics to investigate the structure and compositional diversity of rhizosphere soil microbiota, as well as to profile the terpenes in ChaiHu samples retrieved from six disparate localities with varied cultivation methods and soil characteristics. Additionally, we characterized the physicochemical properties of the soil samples under investigation. Results A total of 130 terpene metabolites were identified in the metabolome of ChaiHu, including 43 Triterpene Saponin, 34 Sesquiterpenoids, 25 Triterpene, 19 Monoterpenoids, 8 Ditepenoids and 1 Terpene. The predominant beneficial bacterium was Haliangium, benzoxazinones, Gaiella, Sphingomonas and Gemmatimonas within the rhizosphere soil of ChaiHu. Subsequently, Gemmatimonas exhibited a significant correlation with total nitrogen (TN), available nitrogen (AN), and nitrate nitrogen (NO3-N). Moreover, Nitrogen and Potassium elements were highly correlated with the quality of ChaiHu. Additionally, intercropping mode not only enhance the abundance of beneficial bacterial but also promotes the bacterial diversity expansion. Conclusion Our findings suggests that the abundance of rhizosphere microorganisms and the profile of soil nutrients play a pivotal role in shaping the quality of ChaiHu. Our investigation delivers insights into the quality formation of ChaiHu, providing a theoretical foundation for its optimal cultivation practices.