Closely related questions been asked several times in different forms on here but I feel like none really spell out what's going on. I have been looking more at glueing schemes, and particularly relative glueing to construct the projective bundle over a scheme and I really want to understand what is going on in terms of colimits in the category of schemes.
I am hoping to break this into two questions since it will be a lot to include in just one. First let's say I just have a pair of topological spaces, $X_{1}$ and $X_{2}$ with $U_{1} \subseteq X$ and $U_{2} \subseteq X$ open sets with a homeomorphism $$ \phi: U_{1} \stackrel{\simeq}{\longrightarrow} U_{2} $$ Now say I want to glue $X_{1}$ and $X_{2}$ along the homeomorphism $\phi$. As a set, this is not hard to write down just as a disjoint union modulo the relation $p \sim \phi(p)$. But what is actually going on here categorically? If there is no gluing involved, then we just have the categorical sum, $$ X = X_{1} \sqcup X_{2}. $$ This has the universal property that to give a morphism from $X$ is precisely to give a morphism from $X_{1}$ and a morphism from $X_{2}$. As someone brand new to the idea of a functor of points, can $X$ then be seen as a representing object for some functor of points?
When we try to incorporate glueing along $\phi$ is when I get more confused. In some sense, I need a colimit that captures the notion:
To give a morphism from $X$ to some $Y$ is precisely to give morphisms $\psi_{1}: X_{1} \rightarrow Y$ and $\psi_{2}: X_{2} \rightarrow Y$ so that $\psi_{1} = \psi_{2} \circ \phi$ on $U$.
I suspect that this is somehow a coequalizer, but I haven't been able to formulate it. So what diagram should I take so that $X_{1} \sqcup X_{2} / \sim$ is the colimit object?
This seems to be complicated even further if I have more than two objects to glue. Say I have a family $\{ X_{i} \}_{i \in I}$ with open subsets $U_{ij} \subseteq X_{i}$ along with homeomorphisms $$\phi_{ij}: U_{ij} \stackrel{\simeq}{\longrightarrow} U_{ji} $$ satisfying the appropriate cocycle condition. Can the resulting space formed from gluing be realized as a colimit of some diagram? Is there some generalization of a coequalizer? And again, can this be realized as the representing object of some functor of points?
Is there any reference either in the category theory or the topology literature that treats gluing explicitly in this way?
I'm hoping to ask another question later specifically about certain colimits in the category of schemes, but I wanted to simplify things first by only considering the topological side of things.
Any insight into this would be appreciated.