Aflatoxin B1 is a strong carcinogenic and toxic fungal toxin produced by Aspergillus flavus and other Aspergillus species, and can seriously threaten the health of consumers and the safety and quality of agricultural products. Aspergillus in agricultural products are closely related to topography and symbiotic microbes. It is not fully clear that how topography affects the assembly process of A. flavus and symbiotic fungi on plant. In this study, we analyzed the structure and assembly process of fungi on the peanut. We also performed the metatranscriptome analysis, identified the functional genes and metabolic pathways enriched in both A. flavus and its symbiotic fungi. In our experiment, terrain and soil properties could significantly affect the gene expression of microbiome, A. flavus abundance and infection ability to peanuts. Meanwhile, the Permanova correlation analysis revealed that differentially expressed genes were strongly correlated with the soil physicochemical factors. Furthermore, metabolomic analysis identified the main metabolites associated with A. flavus and aflatoxin B1, the results proved that the terrain significantly affected the microorganisms associated with peanut pods to produce a variety of metabolites. In conclusion, our results indicate that topography can significantly influence the assembly process of A. flavus and microorganisms, the activation of functional genes and metabolic pathways, the enrichment of aflatoxin-producing fungi.