In the present situation, the growing use of power electronic devices and non-linear loads has led to power quality (PQ) issues, including harmonics and poor power factor, which adversely affect the distribution network. This study contributes a design of shunt active power filter, powered by solar energy and energy storage systems, to address these PQ issues. To minimize losses, a five-level reduced-switch voltage source converter has been considered. Additionally, a neural network-based reference signal generation method is used, eliminating the need for conventional synchronous reference frame and active-reactive power theories, along with their complex abc and αβ0 transformations. This work also includes the optimal selection of the shunt filter and the gain parameters for the proportional-integral-derivative (PID) controller used in the shunt and battery control system. These parameters, along with the weights and biases of the neural network, are optimally determined using a nature-inspired flower pollination optimization algorithm.The proposed system has three primary objectives: (1) stabilizing the voltage across the DC bus capacitor, (2) reducing total harmonic distortion (THD) and improving the power factor (PF), and (3) ensuring the power management under the varying irradiation and load conditions. The effectiveness of the proposed system is evaluated through three testing scenarios, with results compared to conventional SRF and pq methods using a proportional-integral controller (PIC). The analysis reveals that the THD for the case studies is 3.32 %, 2.93 %, and 3.98 %, significantly lower than the other techniques compared. Additionally, the PF is nearly at unity, with a lower settling time of 0.05 s for the DC bus voltage.