It is much, much harder to construct "lines" of defense or attack in 3-D space than on a 2-D map, because the "lines" actually have to be planes. Many of the battle strategies which Humans have been used to deploying - fortifications, blockades, the strategic use of terrain - work well on a 2-D planet's surface but simply don't translate into space. For example: encircling a city with a besieging army is relatively simple; the space-equivalent - encircling a planet with a besieging space fleet - is much, much harder because you need proportionately many many more units to complete a 3-D sphere all the way around the planet.
Many space-warfare games, novels etc counter this extra degree of freedom by creating a universe which generates artifical "choke points" where human-style battle tactics will work much better - like the "jump points" in the old Wing Commander series. ED isn't really a "space warfare simulator", so hasn't been designed with that aspect in mind. So you're stuck, being a 2-D-thinking human trying to defend a 3-D area of space.
For Human enemies using the FSD, the star is your only "choke point". Immobile fortifications ("star bases") will only work if your weaponry is long-range; in ED, space weapon ranges are pitiful, so those are out. All you can do is to deploy an immense battle fleet, encircling the star; hopefully, your fleet is strong enough that it can "hold the line" at the point of entry of the enemy, until the reinforcements from the rest of the fleet arrive. And you'd better hope that the first attack isn't a feint, with the "real attack" coming in from elsewhere after the defending sphere has been called over to engage in the conflict zone.
The FSD arrival points from particular stars are predictable, so it might seem possible to mount some kind of asymetric defense: if you are certain that an attack is going to come from a specific star system, then you can arrange your defending fleet so that the bulk of the fleet is in the vicinity of the enemy's likely arrival point. Of course, in ED, there's really little advantage in launching an invasion from a specific staging area; it doesn't take much time or effort for an invasion fleet to jump into another, random star system, before jumping to their target; there's nothing that the people in that third star system could do to stop them using "their star" as an invasion route waypoint. It would have to be a very, very stupid (or lazy) invasion fleet commander to fall into such an obvious trap.
As for defending against Thargoids, AI or other non-Human invaders: sorry, but without knowing the enemy capabilities, mounting or even planning any kind of defense is futile. Thargoids are known to be able to warp in wherever and whenever they please; your only "defense" there is to mount as large an AX-defensive fleet around your key assets as possible, and have them ready to deploy elsewhere ASAP.