How do I defend my base

Im about a week into this game and Im finally starting to kind of get the hang of it, just as I got myself stocked up on food, some resources and boom Cassandra throws me a raid with a 7/8 red dudes equipped with iron spears and flamethrowers, I was freaking out because I had a grand total of 3 guns and only 4 dudes that can kind of fight but not against flamethrower, so while they were preparing for raid, I was busy barricading and praying hoping that my run wouldnt just end here. Then anamoly DLC happened. an anomaly raid of 17 dudes spawned in the path of the incoming raid and my base(the passive kind where they just lurk around unless they detect other lil dudes). At this point I thought I was dead for sure and I just kinda gave up and let the game run in 4X speed to watch it end but lo and behold, the red dudes ran straight into the Anamoly dudes and got absolutely aliven'ted, the dudes with flamethrowers did a number on the anamoly dudes but the spear dudes are uttlerly destroyed, and I live to see another day.

12/10

So how can I defend my base better? Feels like the raids are getting harder and harder and I am too wealthy for my own good