The transition from linear to non-linear structure formation in cosmology is here studied from the point of view of the thermodynamics of self-gravitating fermions. We start by reviewing the principle of maximum entropy production through which such a fermionic system can relax towards spherical equilibrium states able to explain the dark matter (DM) in galaxies. We then analyze the stability, lifetime and morphology of the above configurations, and show that the most general DM profile develops a compact core governed by degeneracy pressure, which is surrounded by an extended halo. For DM particles which are in the range of $\mathcal{O}$(10--100) keV, we apply this theory to the case of the Milky Way, and show that the compact DM-core explains the dynamics of all the best resolved S-cluster stars orbiting SgrA *, without the need of assuming a central black hole (BH). Further consequences of this theory regarding open issues in cosmology are outlined, including the problem of formation of supermassive BHs in the early Universe.