Entropy change during flow of heat If heat $Q$ flows from the surrounding nature temperature at $T_\text{surr}$ to the system at temperature $T_\text{system}$, then $$\Delta S_\text{total}=\frac{+Q}{T_\text{system}}+\frac{-Q}{T_\text{surr}}$$


This definition is from my book in which heat is exchanged between system and surrounding. This formula for me would only be valid when both the system and the surrounding is undergoing reversible processes but nothing about it is said over here. Does this mean this formula assumes both the heat gained and heat lost are rebersible processes? Isn't entropy defined for reversible processes?
Entropy is a state function, which means its value does not depend on how it gets from state A to state B, rather it only depends on the final state B itself.  In this case, we can imagine a process which takes the system from state A to state B via a reversible process, and your expression for the change in entropy would be correct:
$$\Delta S = \frac{q_\text{rev}}{T_\text{sys}} - \frac{q_\text{rev}}{T_\text{surr}}$$
where I have explicitly labelled the heats as reversible heat flows (this quantity does depend on the path taken).
Even if in reality such a reversible path would not be taken, the final change in entropy would still have the same value, so it is still valid to use that expression.