The use of fossil fuels for energy demand is overgrowing, leading to a higher CO2 emission. Besides, these resources have fluctuating prices and have higher operating costs. Thus, the integration of renewable energy (RE) sources has been increasing throughout the years to reduce the dependency on fossil fuel generation. However, RE generations have high initial costs and intermittent resources. Therefore, it is crucial to conduct technical and economic analysis before the installation of any hybrid energy systems. This study proposes the installation of a PV system for a residential building in Tehran, Iran. The goal of the system is to have a PV system for peak demand reduction. Moreover, the input data also includes economic parameters such as costs of PV, battery, and grid purchases alongside interest rates. Sensitivity analysis also conducted in this study to investigate the variation of load profiles on the optimal system configuration. The simulation results show a 422-kW grid-connected PV system with battery storage is the most optimal system for the selected location. The system has a lower Net Present Cost (NPC) and initial capital compared to other configurations. Moreover, the system also has a higher RE generation and lower energy import from the grid.