Phototrophic communities of photosynthetic algae or cyanobacteria and heterotrophic bacteria or fungi are pervasive throughout the environment. How interactions between members contribute to the resilience and affect the fitness of phototrophic communities is not fully understood. In this work, we integrated metatranscriptomics, metabolomics and phenotyping with computational modelling to reveal condition-dependent secretion and cross-feeding of metabolites in a synthetic community. We discovered that interactions between members are highly dynamic and are driven by the availability of organic and inorganic nutrients. Environmental factors, such as ammonia concentration, influenced community stability by shifting members from collaborating to competing. Moreover, overall fitness was dependent on genotype and streamlined genomes improved growth of the entire community. Our mechanistic framework offers insights into the physiology and metabolic response to environmental and genetic perturbation of these ubiquitous microbial associations.