A major unresolved question in microbiome research is whether the complex ecological patterns observed in surveys of natural communities can be explained and predicted by fundamental, quantitative principles. Bridging theory and experiment is hampered by the multiplicity of ecological processes that simultaneously affect community assembly and a lack of theoretical tools for modeling diverse ecosystems. In the first part of the talk, I will present a simple ecological model of microbial communities that reproduces large-scale ecological patterns observed across multiple experimental settings including compositional gradients, clustering by environment, diversity/harshness correlations, and nestedness. Surprisingly, our model works despite having a “random metabolisms” and “random consumer preferences”. This raises the natural of question of why random ecosystems can describe real-world experimental data. In the second, more theoretical part of the talk, I will answer this question by showing that when a community becomes diverse enough, it will always self-organize into a stable state whose properties are well captured by a “typical random ecosystems”. If time permits, I will also highlight surprising connections between ecological dynamics, constrained optimization, and kernel-based machine learning methods such as Support Vector Machines.