Starbases cost money to operate and to maintain. If you want cash, don't build any except maybe trade starbases, and only in sectors where it is very likely that freighters go through often (a starbase gives money only when the minifreighter is in the same sector).
You need high population and good morale in order to be able to earn money. Not touching the sliders is definitely going to ruin you.
What to do:
1)Increase population.
1.1)This requires morale, so LOWER tax rate until you hit 100% morale. Do this in the early game until you are near debt.
1.2)You also need high PQ to get morale, population and money, so try to build soil / habitat social improvements as soon as possible.
2) Lower spendings until you are no longer in the red.
Repeat: Lower spendings. In the late game, if I do any kind of research at more than 10% with 30% spendings, I will usually go into debt because I have built all those + research buildings (actually for their +influence value)
3)Earn money through buildings.
3.1) Build +cash buildings (banks) and +morale buildings on low morale planets (low = less than 100%). Don't build virtual reality centers, they cost 5 to maintain.
3.2) Do NOT build buildings that will add to your production or research unless you have positive cash flow and are at 100% spending. This extra production will cost you, so you will have to lower your spendings, thus negating part of the benefit, plus you'll have to pay the upkeep cost.
3.3) Production and Resources Starbases: These give you half their bonus as free production, so they are worth having but you will have to lower the spendings in order to lower the amount of paying production (the paying half of the bonus). Plus they have 10bc upkeep cost, so don't build many.
3.4) Rushbuilding: Avoid if you can. Only wonders are worth rushbuilding, or the ship that will save your star system NOW and 100% sure. Don't rush trade goods, colony ships or whatnot. If you do rush, make sure you take the best suited option (usually option 2 for me).
4) Trade.
You need both your trade going to whoever else and everyone else's input. A trade route gives money to both ends of the route.
5) Diplomacy.
5.1) Get those trade routes by paying the ai (with money, tech, influence, ships...) to attack their trade partners. With a bit of luck, they'll reloacte their trade routes towards you.
5.2) Make deals, particularly with minors, selling them techs, ships. Long term gives you more money than short term. This doesn't work very well at maso difficulty level (though the Alexians can give some money).
The ai is not cheating there. The Yor often go into debt, not to talk about the minors.
[Message Edited]