Nice work! Glad to hear you made it through that.
There's a lot of things you can do for that sort of defense, which really isn't that hopeless actually:
1. Minefields strategically in fans out from the wormholes on your planet.
2. Lots of turrets and tractor beams paired with them.
3. Force fields over your important stuff, with turrets OUTSIDE those force fields to help on defending them.
4. A big standing fleet obviously helps.
5. If you are TRULY overwhelmed and it's worth it to spend a few AI Progress points just to survive, you can build some lightning warheads at the missile silo, and have those ready. When the AI is getting ready to come into your planet, they'll gather around the wormhole on their side first for maximum impact. With some well-placed lightning warheads through to them, you can take out huge chunks at them (but at an AIP cost).
6. You can also do clever things with EMP warheads on their side, nukes if you REALLY had to, etc.
7. You can also use your light starships and/or flagships to boost the munitions of your turret balls, or of some mobile ships on defense.
8. You could also use a mobile repair station or similar to help out, and you can set your space docks on loop while producing ships straight into Free Roaming Defender mode (V+right-click) at a certain spot on the planet, so as your defenders die new ones come right in.
And there's other stuff, too, but those are the main ones I can think of and that I use. This sort of defense is actually something you'll be able to routinely deal with as you get more expert with the game, if you're interested in taking things to that level. Not that you'll HAVE to do that all the time, but that you'll be able to in a conscious fashion if it seems strategically advantageous to do so. Often if you want to cap a high-level planet early in the game, that's the sort of thing you'd want to consider doing.