The utilization of renewable energy sources has increased due to concerns about climate change. However, injecting the power from renewable energy sources into grid-tied systems is challenging. The techno-economic analysis a photovoltaic (PV) energy systems is investigated. As a result, this paper presents AC-PV module for Grid-Tied and Off-Grid Scenarios via optimization, modeling, and test results. Even though the output of a PV panel is DC voltage, a three-port inverter and a lithium-ion battery pack are integrated with the back of the PV panel. They are packaged as a PV system module that makes the module output have AC voltage. Therefore, an optimized AC-PV module can be a solution for residential and commercial use, which are grid-tied systems; it can be very efficient for those without access to electricity, which is an off-grid system. An integrated battery and thermal management strategy is crucial for this AC-PV module. In the article, the battery capacity optimization, the electrical and the thermal model of the battery pack, battery heat generation model are discussed by using stochastic analysis techniques; the battery test results are also obtained to identify the models’ parameters and a control algorithm is proposed to extract the battery information such as temperature, current, voltage, SoC and SoH of the battery pack.