Recent Kepler and TESS observations discovered many rocky exoplanets in habitable zones around active main-sequence stars. The upper atmospheres of exoplanets are subject to two important energy sources derived from their host stars. First, the stellar photon flux in the X-ray and XUV bands ionizes and heats the upper atmosphere, driving atmospheric heating, affecting the conductance, and enhancing atmospheric escape. Second, the stellar wind’s interaction with the exoplanet’s intrinsic magnetic field transfers energy to the atmosphere through field aligned currents and Poynting flux.That energy is dissipated in the high latitude cusp and auroral regions through Joule heating which can inflate the atmosphere and also enhance the atmospheric escape rate. This presentation will discuss recent advances in modeling these energy inputs and their consequences for exoplanetary habitability. In particular, we present the development of a new model, the (exo) PLANETary Ionosphere-Thermosphere Tool for Research (PLANET-ITTR). The model and its validation are presented as well as application of the model for two physical scenarios. First, we examine the determination of ionospheric conductance for planetary systems and present verification of the conductance calculation with widely used empirical models for modern Earth. We will also model the case of elevated stellar XUV input appropriate for close-in exoplanets as well as the early Venus and Mars and discuss the consequences for the stellar wind magnetosphere coupling. Second, we study the onset of hydrodynamic escape under conditions of enhanced stellar XUV flux. We will derive the loss time of hydrogen dominated primary atmospheres of terrestrial (exo)planets and sensitivity of the atmospheric loss time scale to various stellar inputs.