Hey there, I'm on the tail end of this exact scenario (also BPI, heyoo). I don't think I'm qualified to give advice but I can share thoughts on what worked for me.

Remember this always: this world isn't meant for us. It's shitty but it's true. You are still fighting the fight and you should be damn proud of that. Keep it up, it never ends, and that makes you a strong human being, no matter what your brain tells you today or the next.

- Changing my expectations for what I can reasonably expect was the first step. Unless you're working with others who have BP or are close to someone who is, you just can't expect anybody to understand, or care. After accepting this, I found it easier to recognize a path forward within the scope of what's reasonable. Freelance as you are doing is a great path. We absolutely require a high degree of autonomy simply because of our on-again-off-again abusive relationship with that thing others fondly call sleep.

- Coding challenges are a pain, but the ones you can do from home are your best friend. Yeah I know they're repetitive and don't really motivate anybody, but work is not a great rainbow party of love all day either. I've found it's mentally stimulating to play around with them, and if solving a puzzle ends in a job, well right on!

- You qualify for disability. Yes, you qualify. You probably qualify for unemployment if you find yourself without a paycheck one month. It's there for exactly this reason! Don't listen to your brain telling you some weird tax misshap from 10 years ago will be brought to the surface and ruin things. You qualify. Figuring out what I needed to have on hand, and what the timeline for submission -> rent/food money was in the event jobs slowed or a particularly extreme episode knocked me on my ass one month, likely eliminated 60-70% of stress I didn't even know I was carrying around. You have a support network, but it does take some bureaucratic boring stuff. Having that sorted helped my peace of mind more than any other thing I think I did.

- Learning the signs of toxicity in a workplace or people I talked with when interviewing has payed major dividends. I was far too naive and trusting for too long. I eagerly got sucked into an interesting project and ignored the giant screaming shitshow just outside my head all day until the job became more insanity than annoying workplace quirks. No more amigo, workplace toxicity is very prevalent (especially in tech/startup worlds for some reason, not sure why or if its anecdotal), and it WILL come back to fuck you over. It's like the show Silicon Valley but not funny, just really sad and miserable to endure. Identifying shitty situations before getting involved has stabilized my life quite a bit.

- For me, my "redemption" in terms of finding a comfortable work situation, was by finding a way to apply my software/research background at companies largely removed from the "tech scene". Hip starups and beanbag massage chairs are cool, but being able to leave my job at 5 every single day is SO NICE.

Stress is the archenemy of BP, I'm sure you know well by now :) The goal of my life is now just to reduce stress any way I can. I can still dream of making it big and doing something great and all that jazz, but we both know if the universe handed us something that spectacular, our brain would find the most contrived way to blow it all up. That scares me, and sometimes just getting out of bed scares the shit out of me. I'm not gonna try to convince myself I'll work hard and do something great because of it.

The only thing I expect from hard work now is that I don't yell some insane shit at my neighbor this weekend. BP is a nutty thing. Keep strong!

This is a throwaway but if you want to chat about anything at all let me know, I'll keep checking the comments here for a few days, and we'll figure something out. You're not alone! You're never alone! There are literally thousands of us :)