In a linear regression setting, I've seen that the $j$th component of the ordinary least square estimator $\hat{\beta}_j$ can be obtained as follows: $$\hat{\beta}_j = Y^T Z^{(j)} / (X^{(j)})^T Z^{(j)}, $$ where $Y$ is the response vector, $X^{(j)}$ is the $j$th column of the design matrix, and $Z^{(j)}$ is the residual vector when regressing $X^{(j)}$ against the remaining columns of the design matrix $X^{(-j)}$.

Could you help me understand why this works? A geometric explanation would be really helpful!