Mechanistic vegetation models serve to estimate terrestrial carbon fluxes and climate impacts on ecosystems across diverse biotic and abiotic conditions. Systematically informing them with data is key for enhancing their predictive accuracy and estimate uncertainty. Here we present the Simulating Optimal FUNctioning rsofun R package, providing a computationally efficient and parallelizable implementation of the P-model for site-scale simulations of ecosystem photosynthesis, complemented with functionalities for Bayesian model-data integration and estimation of parameters and uncertainty. We provide a use case to demonstrate the package functionalities for modelling ecosystem gross CO2 uptake at one flux measurement site, including model sensitivity analysis, Bayesian parameter calibration, and prediction uncertainty estimation. rsofun lowers the bar of entry to ecosystem modelling and model-data integration and serves as an open access resource for model development and dissemination.