Diode / Transistor Confusion

I think it`s called Freewheeling Diode:

https://www.elprocus.com/freewheeling-or-flyback-diode-circuit-working-functions/

Basically to protect the circuit from reverse current from Solenoid when Solenoid is being turn off.