How do you know if a friendship becomes an emotional affair?

This guy and I may be codependent and I dont know how to stop it. He often asked me how i am every 3 days for straight three months and wants to help me and support me emotionally. He was really very caring and acted like my boyfriend with how much he emotionally supported me but I guess he is undergoing problems right now. It doesn't make me feel well because i seem to be affected by him getting affected which shouldn't be the case.

I guess his constant trying to help me and playing as my doctor, visiting me to the hospital, creating my food diet sheet paid off. He gave extreme effort in helping me and in the end, when he suddenly stopped it. I had to ask him and said hope he's okay but i feel uncomfortable with how extremely bonded we are. He never had to tell me his problems, i will know just by his behavior that he is not okay.

He had a partner in the past and i was reminded of the time he will go through periods of isolating when he and his partner fight. The thing is he also isolates from me. But guess what, when they are okay, he also would seek emotional attention and care from me. Plus, he also emotionally supports me for every problem that I have.

Then, in the past, whenever they fight, he goes to me and will go out of his house to talk to me when he is in the gym or in a coffee shop. He never talks to me with his partner around. He also will frequently complain about his partner to me.

Also, it looks like he has not disclose my existence to his girlfriend and he also did not tell me it was his girlfriend, he told me it was his room mate lol. I only found out because a mutual guy friend told me that my guy friend told him.

Why would he tell our mutual friend who is not even close to him that it is his girlfriend but when he talks to me, he tells me it's his room mate?

When i confronted him, he told me it was "irrelevant" or sort of saying it was not needed to be told.

How do you know if a friendship becomes an emotional affair?
Post Opinion