In this study, we investigated the bacterial diversity in rearing water, shrimp (Litopenaeus vannamei) stomach and intestine based on temperature and exposure to wheat flour (carbon source) to determine the correlation between microbial community and surrounding environment in the zero-water exchange shrimp biofloc technology (BFT) system. Three temperature levels of 29 °C (optimal temperature for shrimp growth), 25 °C (rearing water temperature in winter) and 34 °C (summer) were used. Wheat flour was added to groups L (at late stage) and E (at early stage), and sodium bicarbonate was added to group N (wheat flour not added) to adjust the pH. During the operation of the system, the water quality was retained in groups E and N, while it seriously deteriorated in group L at all temperatures. After wheat flour addition in group L, all water quality parameters were recovered efficiently. Using next generation sequencing (NGS) analysis, a total of 26 phyla and 340 OTUs at the genus level were identified in rearing water (the number of samples, n = 31), shrimp stomach (n = 57), and intestine (n = 57). Five phyla, Proteobacteria, Planctomycetes, Actinobacteria, Verrucomicrobia, and Bacteroidetes and 13 bacterial groups related to Phaeobacter, Pirellulaceae, Verrucomicrobiaceae, Rhodobacteraceae, Flavobacteriaceae, Amaricoccus, Marinicellaceae, Acidimicrobiales, C111, Planctomyces, Nitrosomonadaceae, koll13, and Piscirickettsiaceae were found in all samples, representing the core microbiome. Alpha diversity and richness were higher in the shrimp digestive tract, in group E, and at 25 °C compared with the others under each condition. Based on Unifrac PCoA analysis, the samples were clearly classified according to habitat and culture period mostly. The correlation analysis showed that carbon source addition (wheat flour) had a positive correlation with alkalinity and pH, while it was negatively correlated with total ammonia nitrogen (TAN), and nitrate-N concentration in the rearing water (P < 0.05). Temperature was not directly correlated with other environmental factors. The correlation between the core bacterial groups and various environmental factors were estimated. In the rearing water, most core bacterial groups except for major groups in Proteobacteria were negatively correlated with the concentration of nitrogen compounds and positively with alkalinity, pH, and wheat flour (P < 0.05), while the Proteobacteria groups showed opposite patterns. In the shrimp digestive tract, Planctomycetes and Actinobacteria groups positively correlated with culture period (growth stage or weight), while Proteobacteria and Verrucomicrobia groups were negatively correlated. In all habitats, most Actinobacteria were positively correlated with temperature, while Bacteroidetes were negatively correlated (P < 0.05). The present study demonstrated the correlation between environmental factors and major bacterial groups in the shrimp BFT system, and provided useful information to enhance the research and development of a new probiotic strategy and BFT management.