You're getting a lot of responses that answer some of the questions you're asking, but not really addressing the whole picture. There are a lot of techniques and tools you could use to figure out when and how much fertilizer to add, but all of it misses the point. Fertilizer is a band-aid, addressing (usually inadequately) shortcomings of a perverted system, and so are pest-/herb-/fung-icides.
The last question you asked is the key: gardens and farms don't need to replace their soil because they are "feeding" it with organic matter. The organic matter is animal manure, plant litter, or compost (which is... aged animal manure or plant litter). Bacteria and fungi eat that organic matter, larger organisms eat the bacteria and fungi, and plants operate in relation to all of them to uptake the nutrients they unlock from the previously living material. In natural systems, those dead plants feed the next generation in a relatively closed loop.
I've developed something of an obsession with all this recently as I learn through my own garden, and my goal this year is not to use any fertilizers (though I may if I think it's needed), no herbicides or fungicides, and only very little & very selectively applied organic pesticides.
Container gardening can be a bit of a special case, because it's difficult to have a complete ecosystem on a balcony, but integrating organic matter will replenish that too provided you have the soil organisms to do the work. Which is fairly likely.