This research proposes a novel method that combines Proportional-Integral (PI) control, Artificial Neural Networks (ANNs), and Synchronous Reference Frame (SRF) theory to improve the performance of a three-phase shunt Active Power Filter (APF) under fault situations. The main goal is to reduce power quality problems in electrical grids that are having problems, such harmonics and voltage sags. To precisely manage the APF, the reference frame in which the grid voltages and currents are synchronized is identified using the SRF theory. In order to provide quick and precise correction of voltage and current distortions, the PI controller is integrated to control the APF's compensatory action. The PI controller offers trustworthy control while running normally, but during errors or disruptions, its functionality may suffer. In order to overcome this difficulty, a self-tuning filter in the form of an Artificial Neural Network (ANN) is presented, which may adaptively modify the PI controller's settings under fault situations. To maintain ideal filter performance, the ANN constantly learns from the system's reaction and modifies in real-time. This self-adjusting feature makes sure that even in the event of grid failures, the APF maintains its ability to mitigate problems with power quality. The suggested method effectively reduces harmonics, voltage sags, and other power quality disturbances under both normal and fault circumstances, as shown by the simulation results. In complicated electrical grid systems, the combination of SRF theory, PI control, and ANN-based self-tuning provides a strong way to improve the dependability and effectiveness of three-phase shunt Active Power Filters.