I combine both methods. I basically have three independent systems-
Inventory Control
This defines how much of each mineral and boost each room should have as well as total empire amounts. It has some helper functions on top of it for things like "can use resource immediately", which can be used to prioritize market and terminal orders.
For boosts I only track tier3 with the inventory system- tier1 and tier2 are considered building material and always get upgraded in the room they are in.
The sum of all "needs" for each room is greater than the empire need.
Each room also gets assigned a priority mineral family that it produces (typically a mineral that the room itself mines), which means that room is more likely
Terminal Network
This uses Inventory Control to find surpluses and deficits, and then sends resources where they need to go. It only moves base minerals or tier3 boosts, with the exception of GH2O which I will transfer to rooms with X that also need XGH2O.
Alchemy
This controls the labs for each individual room. If there is X in the room it'll look for any tier2 boosts to match, then if there is OH it looks for any tier1 boost it can upgrade.
If there is nothing to upgrade it calculates what tier1 boosts it can make, and filters out the ones there is no need for. It prioritizes based on need (with the exception of GH, which is always the lowest priority). If nothing remains the system attempts to build G (for GH).