It's a normal and common thing that you feel depressed and it almost happen to every teenagers. You will get better later on but you have to wait many years. To talk about it is already a good thing, you did well
First of all, I think it's important to say that your grades cannot measure your worth. Keep telling yourself that you can do it. Whenever you hear that negative voice in your head telling you that you're a failure and you can't do it, realize that it may just be the depression talking and you're not a failure, you can do it. Don't be afraid to reach out to your teachers or your friends to see if they can help you understand the material. And if you fail a test or something, don't beat yourself up about it. Just use that as a cue to see what you need to work on. Good luck. :)