A geometric perspective on irreversible thermodynamics with internal variables