How do I keep myself from falling back into that state?

2018 was an extremely difficult time for me. I had previously broken my back and had to have surgery to fix it and had metal rods inserted to assist with the healing.
In addition to that, my girlfriend broke up with me after I proposed marriage to her because I wasn't the same religion as her and hoped I'd convert before asking her.
Because of everything that was going on, I was extremely depressed and I gained 30 pounds from eating so much and I spent a lot of money on things and I guess I did it to make me feel better, because it were things to enjoy or occupy my mind.
Anyway, I got the metal removed and I feel good. I've finally moved past my ex, and I still have days where it hurts emotional and physically. But I have a great job and my back has had manageable pain for the first time in years. But I'm also fresh out of a relationship that was on for about 6 months.
So far I've done decent of rebuilding my finances and I'm down 11 pounds since February, and I've gone the gym 4 days a week. But how do I keep myself from breaking down in those hard moments and stop from doing the bad things?
I know a lot of it is your mindset, but I'm not sure how to keep myself going and committed to overall fixing myself.
How do I keep myself from falling back into that state?
Add Opinion