Golden buckwheat (Fagopyrum dibotrys, also known as F. acutatum) is a traditional edible herbal medicinal plant with a large number of secondary metabolites and is considered to be a source of therapeutic compounds. Different ecological environments have a significant impact on their compound content and medicinal effects. However, little is known about the interactions between soil physicochemical properties, the rhizosphere, endophytic fungal communities, and secondary metabolites in F. dibotrys. In this study, the rhizosphere soil and endophytic fungal communities of F. dibotrys in five different ecological regions in China were identified based on high-throughput sequencing methods. The correlations between soil physicochemical properties, active components (total saponins, total flavonoids, proanthocyanidin, and epicatechin), and endophytic and rhizosphere soil fungi of F. dibotrys were analyzed. The results showed that soil pH, soil N, OM, and P were significantly correlated with the active components of F. dibotrys. Among them, epicatechin, proanthocyanidin, and total saponins were significantly positively correlated with soil pH, while proanthocyanidin content was significantly positively correlated with STN, SAN, and OM in soil, and total flavone content was significantly positively correlated with P in soil. In soil microbes, Mortierella, Trechispora, Exophiala, Ascomycota_unclassified, Auricularia, Plectosphaerella, Mycena, Fungi_unclassified, Agaricomycetes_unclassified, Coprinellus, and Pseudaleuria were significantly related to key secondary metabolites of F. dibotrys. Diaporthe and Meripilaceae_unclassified were significantly related to key secondary metabolites in the rhizome. This study presents a new opportunity to deeply understand soil-plant-fungal symbioses and secondary metabolites in F. dibotrys, as well as provides a scientific basis for using biological fertilization strategies to improve the quality of F. dibotrys.