To be honest building a good colony mostly requires find good planets with low hazard and lots of resources (you could even build a colony on a habitable world for heavy industries then another one in a volcanic planet with loads of metals solely for mining since industries with high upkeep such as heavy and light industry, military base and fuel production are best kept on low hazard worlds).
When you build your colony it will first be in a shortage of everything, don't panic it's normal since the spaceport isn't functional yet.
The import and export of resources in your colonies depends on your relations with the other factions and distance from the core world (eventually you could make your entire empire self sufficient and go at war with everyone without suffering from any shortage).
Pirate bases will spawn (the stronger the base the bigger the raids and accessibility penalty) once your colony is built, they will target your system with pirate activity which reduces the accessibility of the colony and spawn pirate fleets around it, then they will send pirate raids that will atempt to steal ressources from your colony and reduce stability by 1 for three month (it stacks with each raid) and worse of all they will occasionally target trading convoys which reduces imports.
Likewise luddic path bases will spawn and target your colony if it is too industrious or uses AI cores, these degenerates will set up a pather cell on it and keep attempting to disrupt an industry for as long as the cell is active (the higher the planet defence rating the less likely they are to succeed) again destroy the base to disable the cell or remove anything that angers them to make them go away (but well, we're not going to let degenerates stand in the way of profit are we ?).
If your market share gets too high factions (except hegemony, independents and luddic church I think) will get jealous and send super special tacticool forces to kindly ask you to be more sporting in the free market by blowing up whatever industry they're jealous of. These fleets are technically not officially theirs and will not get you into war with them if an unfortunate accident were to happen and they get destroyed (only -5 rep loss) or if your not confident you can bribe them (but it's stupidly expensive) or ask favours from them and lose -20 rep (but lets be honest you might as well destroy them since you will also get to keep their ships as trophies).
If your colony is set to be a free port (you get money from black market) Hegemony will the start sending the same type of attacks (destroy them too).
If you use too many AI cores the hegemony will send an inspection fleet which will steal all of your cores, reduce your rep with Hegemony for each core found and if you remove them before they arrive they will trash your industry while looking around and disrupt everything, attacking them will make the Hegemony hostile... unless they never knew it was you. Turn your transponder off, wait for them to arrive and say it was a pirate attack and only lose 5 rep.
The size of pirate raids depends on size of the base they came from, anti industry fleets size depends on how many expeditions you defeated before and Hegemony AI inspection scales by the number of AI cores.
Some of the most important things for a colony is an orbital station which should defeat all expeditions at the star fortress level except for the craziest of Tri Tach and Hegemony fleets. The patrol HQ/military base in order to keep your com relays under control, clean up pirate fleets and weaken expeditions. And arguably the most important one a heavy industry/orbital works equiped with a nanoforge (I hope you haven't sold your nanoforge you dingus) which massively improves the size and quality of patrol fleets and allows you to build your own ships for personal use. Then there is the ground defence that boost the defence rating even further and finally the waystation that gives a good boost of accessibility.