Non-equilibrium thermodynamics of heterogeneous systems