Been depressed since 9th grade, was on meds for a few years then stopped. Chronic depression doesn't go away, you just learn to live with it.
It's mostly rooted in some trauma or your understanding of the world . Can also be biological (for me it was all three).
Meds helped me a lot to stabilize for a good few years, but i realised it wasn't a long term solution for me. Therapy has also helped a good amount but it's a long term process. India doesn't have enough good therapists sadly, I've consulted with almost 10 different therapists and psychiatrists so far. Happy with my current therapist, we speak rarely (maybe once a year now), but he asks good questions and has good advice whenever we do.
Keeping depression and insomnia at bay basically requires you to bring some discipline in life. Making time for hobbies, exercise and diet (very important), people you like and people who like you, going on dates once in a while, learning new things, helping people/volunteering etc.
The goal is to fill your day with enough things such that you fall asleep as soon as you hit the bed. Your body needs to tire out and reset properly.
There is much to do and see in the world, make full use of your time and find good work that can consume you. Depression will be much easier to deal with.