I am reading an introductory book on Linear algebra.
In chapter 4, the author presents QR factorization like this:
I completely understand the Gram-Schmidt process, but I am struggling to grasp how the author is deriving these equations (the highlighted parts).
Also, what's the meaning of r variable here. The author suddenly starts using it without giving any explanations.

The equation involving $q$ is exactly Gram-Schmitz or at least the start of it. It is actually just the orthogonal decomposition formula.
The variable "r" is as introduced for normalization. Basically the author wants to do everything in orthonormal basis.