Over the years, there have been efforts to understand the thermodynamics of solar cells so that the physics can be better improved. Heat generation in photovoltaic (PV) modules (which contain solar cells for direct electrical energy generation) has been acknowledged in many literatures as a key power degradation parameter. At the moment, an accurate modeling of photovoltaic power generation requires a computational iterative model since the output voltage of a PV creates a transcendental equation. This study uses code-based model (CBM) which allows user defined codes to implement a novel integration of solar, electrical and thermal exergies of photovoltaic module in order to create a thermophotovoltaic model. After integrating the proposed model in MATLAB, parametric studies were carried out to understand how changes in temperature and solar radiation affect the electrical and thermal exergy flows during power generation. Interestingly, results show that heat is essential for power generation although it should not exceed the critical value beyond which the voltage would start deteriorating. At 290 K, the electrical exergy flow of the 45 W PV module used in this study was 41.46 J/s and the overall improvement in exergy could be up to 51% if the waste heat generated is utilised for useful thermal work. The energy and exergy efficiencies of the PV module were initially the same but the energy efficiency degraded because of the reduction in the open circuit voltage ( V_oc) as temperature increased. Lastly, insights from this study is purposed to increase the understanding of how electrical and thermal exergy flow pattern in the PV module can be managed to either stabilise its temperature through cooling and surface treatment or facilitate its heat recovery for photovoltaic-thermal applications.