Okay here goes some tips, some have already said, but its good to refoircement them
- explore all you can. Yeah you have to fly and all that, but what i try to do is zig-zag in the stars, trying to rreach the exit in the last safe jump. Also, even if they can be dangerous, i prefer take nebulas, since they delay the persuit (1/2 in normal sector, 1/4 delayed in nebula's one)
- try to plan your weapondry, lazers beams cant go throught shields, so you should get also good ion weapons or rockets/bombs (i always try to get one of missile consuming weapon), also remember in 2nd phase in flagship he uses an defense drone, so you have to be extra careful while picking the weapons.
Always take in mind the maximum capacity of weapons system is 8 power bars.
-try to aim critical systems, what i usually do is:
a)shoot all at once to destroy weapondry or shields
b) if shields are too strong, focus all there.
c) if i get too much missed shots, then i aim for cockpit (if the pilot is gone or if that system is destroyed, all your hit will hit, unless it gets cloaked)
d) Medbay if i have a teleporter strategy (invading to kill all enemy crew

)
-Shields lvl4 can be good, but lvl3 is enough, raise the engines for more evasion, since while shields block 1 shot, engines can end having around 50% chances of evading
each shot.
-If you dont need the medbay at the moment, you can turn it off and use a free power bar somewhere else
-Ion weapons "stun" a system for 5 secs, and if before fading off another ion volley hits it again, it adds a new ion level, and adds 5 secs more. This way you can take a huge shield, if any shot dont miss.
Okay now for FlagShip focused tactics:
-what i try to get before facing it is the cloak system (lvl 1 is enough) and defense drone(*) and upgraded sensors and doors, and every else
(*)the defense drone is just for the missile weapon, so if you can disable that turret fast it doesnt matter at all
Okay first phase:
.Deploy Defense drone (if have one) and turn it off, so you can use the energy for other system, like engines.
-Try to ride off its shields by spamming attacks on it (also try to kill enemy crew), if you have a missile weapon, you can aim with it to the cockpit, disabling enemy evasion if destroyed, halving if you kill the pilot, but they got replaced quickly)
-When you see the missiles are launched, use cloak (pause the game to have more reaction)
-If you managed to destroy the missiles turret, aim for the ions or kill more crew (destroy medbay if you use teleporter invaders), but i recommend to leave the guy in middle left turret alive.
Okay i think that would be enough to pass first phase, now second one, for me, it can be a pain:
-If you destroyed the missile torret, it will be fixed anyways, but the crew in it will be gone (if you killed him). Get rid off it again
-use the cloak against the power surge, when you see a lot of droids deploy, cloak immediatelly
-You should focus on the droids system, to disable a few attacking drones and the invading one (power surge still works even if you fully destroy its system

)
-You can shoot missiles since the enemy has a defense drone, unless you shot more than one at once, keep it for after you damage the drone system.
-Good luck with this one.
Third Phase, rather easy if you killed all or almost all the enemy crew and if you can deal with the missile turret (again):
-the enemy shall teleport to your ship,if you get lucky the appear near a exit door, so you can try asphyx them.
If there is any door nearby, dont worry, deal with them if they attack of a system, or if they arei n a hallway, they will try to reach the O2 room, so you can vacuum that room and the way to reach there (without touching the doors the enemy is attacking or is going to attack next)
-the cloak shall be used against the laser power surge, if you have engines lvl4 or 5, you may evade all the volleys if you cloak just as when it shoots.
With enemy crew dealt (try destroy medbay so they take longer to recover) and missile turret left, the only menace would be the middle left turret, but since it has only 3 shots, your lvl3 shields would be enough
Well good luck with all that, it took me a lots of tried to be able to defeat the flagship, in my first tries i even used to die before even sector 4 xD so don't worry, this game is about learning your mistakes
Also, when i mentioned to keep the middle left turret guy alive in flagship, its because if you kill all the crew, the flagship turns into an automated version, autoreparing itself, but if you accidentally kill it

you can keep this in mind: it cant autoreapair if its on fire or with a huge hole on the floor!
Well good luck and never give up! The Federation is counting on you!