In microbial communities, the ecological interactions between species of different populations are responsible for the spatial distributions observed in aggregates (granules, biofilms or flocs). To explore the underlying mechanisms that control these processes, we have developed a mathematical modelling framework able to describe, label and quantify defined spatial structures that arise from microbial and environmental interactions in communities. An artificial system of three populations collaborating or competing in an aggregate is simulated using individual-based modelling under different environmental conditions. In this study, neutralism, competition, commensalism and concurrence of commensalism and competition have been considered. We were able to identify interspecific segregation of communities that appears in competitive environments (columned stratification), and a layered distribution of populations that emerges in commensal (layered stratification). When different ecological interactions were considered in the same aggregate, the resultant spatial distribution was identified as the one controlled by the most limiting substrate. A theoretical modulus was defined, with which we were able to quantify the effect of environmental conditions and ecological interactions to predict the most probable spatial distribution. The specific microbial patterns observed in our results allowed us to identify the optimal spatial organizations for bacteria to thrive when building a microbial community and how this permitted co-existence of populations at different growth rates. Our model reveals that although ecological relationships between different species dictate the distribution of bacteria, the environment controls the final spatial distribution of the community.