The perovskite device, incorporating a modified nanostructure of TiO2 as the electron transport layer, has been investigated to enhance its performance compared to the pure TiO2 device. Various materials undergo electrochemical doping or treatment on TiO2 to improve their photocatalytic application, thereby enhancing the current density, minimizing recombination, and improving device stability. In this study, a numerical SCAPS simulation was employed to validate experimental findings from the literature. According to the literature, this marks the first instance of doping Al3+ and Mg2+ on TiO2 due to their ionic radius comparable to that of Ti4+, at different doping concentrations. The device was modeled and simulated with the experimental parameters of bandgap, series, and shunt resistances for pure TiO2, aluminum-doped TiO2 (Al-TiO2), and magnesium-doped TiO2 (Mg-TiO2). From the validated results, the Al-TiO2 and Mg-TiO2-based devices' configurations with minimum percentage errors of 0.427 and 2.771%, respectively, were selected and simulated across nearly 90 (90) configurations to determine the optimum device model. Optimizing absorber thickness, bandgap, doping concentration, metal electrode, as well as series and shunt resistance resulted in enhanced device performance. According to the proposed model, Al-TiO2 and Mg-TiO2 configurations achieved higher power conversion efficiency values of 19.260 and 19.860%, respectively. This improvement is attributed to the reduction in recombination rates through the injection of a higher photocurrent density.