What category is the universal property of the Free Group a diagram in? wikipedia says that the free group is defined by a universal property:

The free group $F_S$ is the universal group generated by the set $S$. This can be formalized by the following universal property: given any function $f$ from $S$ to a group $G$, there exists a unique homomorphism $φ: F_S → G$ making the following diagram commute (where the unnamed mapping denotes the inclusion from $S$ into $F_S$):




My question is, in what category is this a diagram? Is it in Grp or Set? Either way I'm confused, because $S$ is not a group, suggesting it's in Set, but the uniqueness of $\phi$ only holds for homomorphisms, not general functions, suggesting this is in Grp.

As the definition mentions, $f$ and the unnamed inclusions are just functions while $\varphi$ is a group homomorphism. Hence the diagram is not in $\mathbf{Grp}$, nor actually in $\mathbf{Set}$ (in the sense that the diagram in $\mathbf{Set}$ would not force $\varphi$ to be a group homomorphism).
The construction gives in fact a functor from $\mathbf{Set}$ to $\mathbf{Grp}$ assigning to each set $S$ the free group $F_S$, and to each function $g:S\to T$ the morphism $\varphi_g:F_S \to F_T$ associated to the map $f=\iota_T\circ g:S\to F_T$ by the universal property (where $\iota_T:T\to F_T$ is the inclusion).
