Let $P$ be a free R-module such that $\{p_1,\cdots,p_n\}$ is a basis. To show that $P$ is projective we need to show that if exists $ a: M \rightarrow P $ surjective and R-linear, then $M = \ker(a) \oplus P_1$ with $M$ as a R-module and $P_1 \cong P$.
Here's what I've got by now:
Assume that there is such R-homomorphism $a$. Since it is onto, it follows that $p_i = a(m_i)$ for $m_i \in M$. Now, consider the following homomorphism: \begin{align*} b:P &\rightarrow M\\ \sum r_ip_i &\mapsto \sum r_im_i \end{align*} That homomorphism exists since there are at least $n$ different $m_i$'s in $M$ by our previous conclusion, and it is well defined since $P = Rp_1 \oplus \cdots \oplus Rp_n$.
It follows that: $$ ab(p_i)=a(m_i)=p_i \implies ab(p) = p \quad \forall p \in P \implies ab(p) = \mathbb{1}_P $$ Now, see that if $m \in \ker{a}$ then $m = m - ba(m)$ because $a\big(m - ba(m)\big) = a(m) - aba(m) = a(m) - a(m) = 0$. Therefore we can write any element of $m$ as: $$ [m - ba(m)] + ba(m) $$ and the first term is in $\ker(a)$ and second term is in $b(P)$, hence: $$ M = \ker(a) + b(P) $$ Now suppose $m \in \ker(a) \cap b(P)$. It follows from $m \in \ker(a)$ that $m = m-ba(m)$. It follows from $m \in b(P)$ that $m = \sum r_im_i$. Therefore: \begin{align*} m &= m - ba(m)\\ &= \sum r_im_i - ba\left(\sum r_im_i\right)\\ &= \sum r_im_i - b\left(\sum r_ip_i\right)\\ &= \sum r_im_i - \sum r_im_i = 0 \end{align*} And we conclude that $\ker(a) \cap b(P) = \{0\} \implies M = \ker(a) \oplus b(P)$. Now it remains to show that $b(P) \cong P$. For that, see that: $$ b(P) \cong M/\ker(a) \cong a(M) = P \implies b(P) \cong P $$
Can someone please check my proof? The part of show that $M = \ker(a) + b(P)$ was a bit tricky but it eventually came.
Thanks and any constructive critics about the proof is highly appreciated.