Solar-based distributed energy systems (SDES) are gradually gaining international attention in the renewables expansion. The energy storage systems bring the desired adjustment flexibility to the demand but also make it challenging to maximize system comprehensive performance. Therefore, this paper is focused on investigating the impacts of the demand flexibility on the SDES and finding an optimal solution that simultaneously and synergistically considers both the design and the operation of the system. In the conducted study, the impacts of batteries and thermal energy storage on the supply-demand gap and permissible load region were compre-hensively investigated. The results of the analysis indicate that 'Strategy 1' performs well in terms of technical and environmental performance, but lack performance in terms of economics as the lack of negative demand flexibility results in the highest installed capacity of the prime mover. Hence, different principles and strategies were proposed to balance the negative flexibility and the supply-demand gap, as well as to exploit the potential for an increased economical, technical, and environmental performance. In the end, various strategies, including a nondominated sorting genetic algorithm (NSGA-II), were employed to optimize the installed capacities of the SDES so that both the design and the operation of the system could be optimized collaboratively to maximize the system benefits. The results of the proposed optimization showed that the lowest annual cost can be reduced by 37.46 %, from 9.45 x 104 USD to 5.91 x 104 USD, when compared to the traditional case. In addition, the multi-objective co-optimization presented a 38.32 % reduction in annual total cost, however with a deterioration of 5.83 % in both primary energy saving ratio and CO2 emission. In terms of the utility of the findings for potential practical installations, based on the obtained simulation results, a full and a 0.45 negative flexibility reserves are suggested for the cooling and non-cooling demand periods, respectively.