I was reading the pullback definition on https://en.wikipedia.org/wiki/Pullback_(category_theory)#Commutative_rings and one of the examples was the existence of pullbacks in the category of rings. Then it says that for the category of modules, the pullbacks are similar.
So, if I have $A,B,C$ objects in the category of left R-modules and two morphisms $f: A \rightarrow C$, $g:B \rightarrow C$ I say that $(P,p,q)$ will be the pullback of $f,g$ with $$P = \{(a,b) \in A \times B: f(a) = g(b) \}$$ and $p: P \rightarrow A$, $q:P \rightarrow B$ defined as $p(a,b) = a$ and $q(a,b) = b$. For the definition of $P$, we have $f(p(a,b)) = f(a) = g(b) = g(q(a,b))$ so the diagram commutes. Now for any $P'$ an object in the category of modules and two given morphisms $p': P' \rightarrow A$ and $q': P' \rightarrow B$ such that $f\circ p' = g \circ q'$ I define the morphism $h:P' \rightarrow P$ as $h(x) = (p'(x),q'(x)).$ See that $h(x)$ is well defined because $f(p'(x)) = g(q'(x))$ so $h(x) \in P$. This satisfy the universal property that $p(h(x)) = p((p'(x), q'(x))) = p'(x)$ and $q(h(x)) = q((p'(x), q'(x))) = q'(x)$ so $p' = p \circ h$ and $q' = q \circ h$.
This will be the proof following the same idea in the wikipedia link, my question is, is $P$ a left R-module? what would it be the product $A \times B$ considered here? I want to give a rigorous proof of this and I want to fill those details. Thanks
We need to give $P$ a left $R$-module structure in order to show that it is the pullback in the category of $R$-modules. Thankfully, this structure is pretty simple: it's given by
$$(a, b) + (a',b') = (a + a', b + b')$$ $$r \cdot (a, b) = (r \cdot a, r \cdot b)$$
It's easy to show that these operators are well-defined and satisfy all the axioms of an $R$-module (in particular with $0 = (0, 0)$). From there, one would need to show that the functions $p$ and $q$ are $R$-module homomorphisms. Finally, you would need to show that if $p'$ and $q'$ are left $R$-module homomorphisms, so is the induced map $h$ as you defined it.
This shows that $(P, p, q)$ is the pullback in the category of left $R$-modules.