In Multiplayer, repair bays are the primary defensive structure. Usually, repair bays are built first, as they can support a fleet as well as static defense. If a world needs to be held against serious attack, a SB is added, and hanger bays are sometimes added in later. Hangers can added a nice boost. In addition to fighters to keep bombers off your SB, TEC get flack to kill bombers, Advent get shield bestowal, which gives everything extra shields and (I think) helps SBs sheilds regen faster. Vasari can trap enemy strike craft out of the battle in phase space.
Usually, though, it's just the repair bays, because fleet is usually preferable to static defense. Fleet can be moved, static defense is stuck in the gravwell.
And to hold pirates? 1-2 repair bays and a level 1 cap ship. Kills the pirates, levels up the cap.