Photovoltaic (PV) has been extensively applied in buildings, adding a battery to building attached photovoltaic (BAPV) system can compensate for the fluctuating and unpredictable features of PV power generation. It is a potential solution to align power generation with the building demand and achieve greater use of PV power. However, the BAPV with battery energy storage system (BESS) is now still facing significant challenges in economic system d. Photovoltaic (PV) has been extensively applied in buildings, adding a battery to building attached photovoltaic (BAPV) system can compensate for the fluctuating and unpredictable features of PV power generation. It is a potential solution to align power generation with the building demand and achieve greater use of PV power. However, the BAPV with battery energy storage system (BESS) is now still facing significant challenges in economic system design, high-efficiency operation, and accurate optimization. This paper aims to present a comprehensive review on the effective parameters in optimal process of the photovoltaic with battery energy storage system (PV-BESS) from the single building to the energy sharing community. The key parameters in process of optimal for PV-BESS are recognized and explained. These parameters are the system's applicability, optimization methods, optimization objectives, and optimization constraints. Moreover, details on the advantages and disadvantages of different optimization methods for the PV-BESS have been analyzed. The current issues and existing challenges are highlighted to identify the gaps for future research. This paper provides a clear picture to the researchers in the field of the PV-BESS and a reference for researchers to understand and further investigate the PV-BESS in depth.••••Photovoltaic with battery energy storage systems in the single building and the energy sharing community are reviewed.••Optimization methods, objectives and constraints are analyzed.••Advantages, weaknesses, and system adaptability are discussed.••Challenges and future research directions are discussed.PV-BESSSingle buildingEnergy sharing communityOptimization methodsOptimization objectivesOptimization constraintsAs the energy crisis and environmental pollution problems intensify, the deployment of renewable energy in various countries is accelerated. Solar energy, as one of the oldest energy resources on earth, has the advantages of being easily accessible, eco-friendly, and highly efficient. Moreover, it is now widely used in solar thermal utilization and PV power generation. In PV power generation, it has been widely used in countries worldwide with a gradual decline in cost. In the past five years, the global PV installation rate has increased by 56.7 %. And in China, as many as 48.2 million kilowatts of PV were installed nationwide in 2020, with an 81.7 % increase compared to the same period last year.Building energy consumption occupies about 33 % of the total global energy consumption. The PV systems combined with buildings, not only can take advantage of PV power panels to replace part of the building materials, but also can use the PV system to achieve the purpose of producing electricity and decreasing energy consumption in buildings. The BAPV systems can be broadly divided into two categories, off-grid and grid-connected PV systems. Furthermore, there are three forms of the off-grid PV systems, the hybrid PV system, the no battery system, and the battery system, respectively. In order to ensure system power stability, the hybrid PV system and the battery system a. In the early development of the BAPV system, the off-grid PV system was usually used. Nevertheless, the peak of its PV power generation does not occur simultaneously as the peak of building electricity consumption, making PV power generation often underutilized. However, in the grid-connected PV system, a large amount of intermittent and fluctuant PV power surges into the grid, exacerbating the problem of temporal imbalance between the buildings and the grid. Fig. 1 shows the “duck curve” of independent operators in California from 2012 to 2020, which suggests that buildings have the lowest demand for electricity at noon and peak demand in the evening, especially at dusk. While PV power generation usually reaches its maximum at noon during the day; the power generation drops or even becomes zero in the evening. Through heat and cold storage systems, batteries, and other energy storage methods, which can realize the shift of power demand between noon and evening of the “duck curve”.Adding the battery in the PV system not only can transfer peak generation to meet peak consumption, but also can utilize TOU tariff to charge the battery at low tariff and discharge the battery at high tariff to realize price arbitrage, which provides a new idea for efficient utilization of the PV system. However, the installation of the battery in PV system also poses several challenges to syste.