In the following document about projection onto subspaces, the author is computing the transformation matrix to project a vector $b$ onto a line formed by vector $a$.

Since the projected vector $p$ is on the $a$ line, therefore it can be expressed as $p = \bar{x}a$. The projection "line" which is the vector $b - p$ is orthogonal to $a$. This means the dot-product of these two is zero:
$$a \dot{} (b - p) = a^T(b - \bar{x}a) = 0$$
It comes to the conclusion that $\bar{x} = \frac{a^T b}{a^T a}$ so
$$p = ax = a \frac{a^T b}{a^T a}$$ (Which I fully understand)
Then the objective is to find the projection matrix P such as $p = P b $. The author wrote that $p = \bar{x}a = \frac{aa^Ta}{a^Ta}$ and so $P = \frac{aa^T}{a^Ta}$
How does he deduced this last part? I cannot see how he goes from $$p = \bar{x} a = \frac{a^T b}{a^T a} a$$ to $$p = \frac{aa^Ta}{a^Ta}$$
And even then, why would $P$ be $\frac{aa^T}{a^Ta}$ since there are absolutely no $b$ in this last expression to identify a $p = Pb$ ?
You can use this way to verify: Let $a=\binom{a_1}{a_2},b=\binom{b_1}{b_2}$. Then \begin{eqnarray} p&=&\bar{x}a=\frac{a^Tb}{a^Ta}a=\frac{a_1b_1+a_2b_2}{a^Ta}\binom{a_1}{a_2}\\ &=&\frac{1}{a^Ta}\binom{a_1(a_1b_1+a_2b_2)}{a_2(a_1b_1+a_2b_2)}\\ &=&\frac{1}{a^Ta}\left(\begin{matrix}a_1^2&a_1a_2\\ a_1a_2&a_2^2 \end{matrix}\right)\binom{b_1}{b_2}\\ &=&\frac{1}{a^Ta}aa^Tb \end{eqnarray} Thus $$ P=\frac{1}{a^Ta}aa^T. $$