Doesn't sound like he is flirting necessarily but more like he is venting his frustrations to you. Sounds like he's looking for an ego boost from a young woman because he can't get that praise and attention elsewhere.
Run! He's either using you as free therapy or is attracted to you (neither are good). Your interactions have a clear power dynamic and the one at most risk is you! You are not his therapist, friend, mom, sister, girlfriend or wife and therefore not the person he should be sharing anything like that with.
It's a red flag for a teacher to get too close to a student and highly inappropriate due to the position of power he holds over you and your education. Keep your contact with him reduced and professional (be careful about how you do this so that your grades are not negatively affected). If you find out that he is attracted to you, report it to the uni.
A man in his position could take advantage of you and has no business entertaining close friendships or relationships with 21 year olds, especially ones he teaches!
If you have a crush on him, step away and recognise this as a risk factor that makes you vulnerable to trouble you don't need in your life. You can never have a relationship on equal footing with this man. There are already enough older men in the world that want to use younger women to boost their egos, even worse when they have the power to affect your future in some way.