How do you maintain your sense of self in a relationship?

After my relationship went down in shambles with my DA ex (I’m disorganized but was AP with her), I realized that I went head first blindly and placed all my worth, validation, and a lot of my identity in her hands metaphorically speaking.

It made me super depressed while I was in the relationship constantly beating myself up for not being enough for her, and made the breakup the worst thing I’ve ever dealt with emotionally, seriously. Went to therapy weekly for a while because of it.

Just hit month 7 since the breakup and I think everything is finally letting up (thank god) and my sense of self worth and self validation is back and better than ever.

I was actually talking with a girl a month ago who was seriously AP and that lasted for a week and a half and things went very quick due to her over investing and me feeling the fear of losing myself in another person again. So I learned that now I kind of have a fear of falling deep into infatuation/love again because of the pain the last breakup caused me.

So I want to ask, how does a secure person navigate this predicament? I want to be in love and eventually get married, but I don’t want to lose myself in a person again so much so that the pain is unbearable when the end comes, and I don’t want to drift into avoidant tendencies.

Advice from secure people please