Microbial communities are of huge importance across all of biology. With specific reference to our own species, a healthy microbiome is essential to human health, and conversely pathogenic bacteria pose an increasingly significant health threat. The latter due to the spread of antimicrobial resistance (AMR). This spread is greatly accelerated by AMR genes often being located on mobile genetic elements (MGEs) such as plasmids which can rapidly disseminate resistance across species lines. In this work I first aim to elucidate the forces shaping the assembly of bacterial communities, using experiments and mathematical models. I then bring in theory from network ecology to better understand and predict the spread of AMR conferring plasmids. Again I make use of experimentation and theory, but with the addition of data from a natural microbial community. In the early chapters I show that spatial structure reduces the impact of environmental variation on community structure and that resource diversity increases stochasticity in community assembly. The in the later chapters I show in silico, in the lab and in a wastewater community that beneficial AMR plasmids form better connected bacteria-plasmid interaction networks, which will have significant ramifications for the spread of AMR.