While the immediate cause of your depression could be chemical imbalances in your brain, other health issues, or life circumstances that are out of your control, the ultimate cause is distance from God, because He has the power bring about all of the right circumstances that would cure the depression. As the Quran says:
Whosoever fears God, God will create for him a way out. (The Quran, from verse 65:2)
This way out of depression will probably not be something obvious and instantaneous, it will be subtle changes in your life that lead you out of it, if you continue to be patient and thankful, instead of jumping right back into a sinful and heedless lifestyle as soon as the sadness is gone.
When hardship befalls someone, they return to righteousness and seek God ardently. When the hardship is lifted, they go back to a life of heedlessness, only doing the minimum that Islam asks of them and engaging in minor sins. God sends them a new hardship to cause them to become pious again. They return to worshiping God properly and showing Him proper respect, until hardship is lifted, only for them to go back to heedlessness.
The way to break out of this cycle is to seek God during times of ease as ardently as during times of hardship, so that you no longer need hardship to make you truly heedful. As long as times of ease cause heedlessness in you, you will suffer hardship.