The single worst thing you can do for both your defense and offense is to build (or upgrade) traps and turrets. Turrets do NOT improve your defense. Upgrading walls is fine, but you really want to unlock and upgrade armory defensive equipment. I have a level 7 minibase with 15K medals that i use to donate snipers to my main base. It has two level 1 burst turrets, no traps or shields. I've had it about three months, and it is something like 79-8 on defense. I three star all hd's. The key is running storm, mhc, and sniper gr, having level 8 avas in the sc, and getting attacked by level 5's (lol).
The matchmaking algorithm in this game is idiotic. Hopefully, if enough minibases are built, the devs will get a clue and stop punishing people for building and upgrading their bases. I'm not holding my breath.