Welcome to blueVoices!! :)
How your boyfriend is treating you is unfair. Him being violent (hitting you!) and mean is not your job to bear, regardless of him being depressed or your boyfriend or not.
I suggest you sit him down and talk to him about it. Tell him how you feel - emphasise that you care for him and is upset about how he is treating you. Suggest that he should see a medical professional (GP, psychiatrist or counsellor). If he is sensitive about the topic, you can tell him that you want to go too.
If he doesn’t listen to you nor to someone that you both trust (e.g a mutual close friend), and continues being violent even though you have tried your best - I suggest you leave the relationship. It isn’t your fault that he is feeling that way and you don’t deserve to be hit.
I hope it works out for you! Keep us updated :)