The modeling and optimization of a community microgrid situated in an urban area is presented in this paper. Such communities include places like housing estates, large hospital complexes, large residential complexes, and universities of higher learning. The case study used in this work is a housing estate situated in Cape Town, South Africa. Distributed energy resources used in the study are diesel generators, rooftop solar photovoltaic system, and the electrical load that is segmented into critical and non-critical type. The segmentation of the load allows an intelligent load shedding scheme in order to maintain the stability of the overall system. HOMER modeling software environment is used to model and optimize the community microgrid component sizes for technical and economic feasibility. An optional grid-connected mode as a backup energy system is evaluated against the grid-forming mode of the community microgrid system. Simulation results are obtained and discussed. Conclusion of decision-making about using a grid-forming microgrid system or grid-connected-PV is presented.