I'm trying to understand the concept of the relative spectrum of a sheaf of quasicoherent algebras. Here is the situation: We are given a scheme $X$ and a quasicoherent sheaf of $\mathscr{O}_X$-algebras (i.e. a sheaf of algebras that is quasicoherent as an $\mathscr{O}_X$-module) $\mathscr{B}$.
Consider the contravariant functor $F = F_{\mathscr{B}, X}$ from schemes to sets that acts on objects by $$W \mapsto \{(\mu : W \to X, \varphi : \mathscr{B} \to \mu_* \mathscr{O}_W )\}$$ where $\mu$ is a morphism of schemes, $\varphi$ is a morphism of $\mathscr{O}_X$-algebras, and the right hand side is the set of all such pairs. The functor $F$ acts on morphisms $a : W' \to W$ by \begin{align} F(a) : F(W) &\to F(W')\\ (\mu, \varphi) &\mapsto (\mu' = \mu \circ a, \varphi' = a^* \varphi), \end{align} where $\varphi' = a^*\varphi : \mathscr{B} \to \mu_* \mathscr{O}_W \to {(\mu')}_* \mathscr{O}_{W'}$ in the composition of $\varphi$ with $\mu_* a^\#$, where $a^\# : \mathscr{O}_W \to a_* \mathscr{O}_{W'}$ (note $\mu_* a_* = (\mu \circ a)_* = (\mu')_*$)
The idea is that we get an affine morphism of schemes $\beta : \underline{\mathrm{Spec}}_X\mathscr{B} \to X$ and morphism of $\mathscr{O}_X$-algebras $\phi : \mathscr{B} \to \beta_* \mathscr{O}_{\underline{\mathrm{Spec}}_X\mathscr{B}}$ such that the pair $(\underline{\mathrm{Spec}}_X\mathscr{B}, (\beta, \phi))$ represents the functor $F$. That is, $F(-) = \mathrm{Hom}_{\mathrm{Sch}_{/X}}(-, \underline{\mathrm{Spec}}_X\mathscr{B})$ and $(\beta, \phi) \in F(\underline{\mathrm{Spec}}_X\mathscr{B})$ corresponds to the identity morphism under the bijection $F(\underline{\mathrm{Spec}}_X\mathscr{B}) \cong \mathrm{Hom}(\underline{\mathrm{Spec}}_X\mathscr{B}, \underline{\mathrm{Spec}}_X\mathscr{B})$. The scheme $\underline{\mathrm{Spec}}_X\mathscr{B}$ is called the relative spectrum of $\mathscr{B}$ over $X$.
How do we get this scheme and universal maps? As usual, we start with the affine case. Suppose $X = \mathrm{Spec}(A)$. Then since $\mathscr{B}$ is quasicoherent, it must be o.t.f. $\mathscr{B} = \tilde{B}$ for some $A$-algebra $B$. This gives a structure morphism $\beta : \mathrm{Spec}(B) \to \mathrm{Spec}(A)$. The multiplication map $B \otimes_A B \to B$ taking $b \otimes b' \mapsto b b'$ induces a morphism of qcoh $\mathscr{O}_{\mathrm{Spec}B}$-algebras $\beta^* \mathscr{B} = \widetilde{B \otimes_A B} \to \tilde{B} = \mathscr{O}_{\mathrm{Spec}B}$, and hence by adjunction a map $\mathscr{B} \to \beta_* \mathscr{O}_{\mathrm{Spec}B}$. We claim that this data represents the functor $F_{\mathscr{B}, \mathrm{Spec}(A)}$. This is proved in https://stacks.math.columbia.edu/tag/01LT, but there are some things I don't understand. The idea is fairly clear, We must show that for all schemes $W$, the map $$ \mathrm{Mor}_{\mathrm{Sch}}(W, \mathrm{Spec} B) \to \{(\mu, \varphi)\} \hspace{10pt} a \mapsto (a^* \beta = \beta \circ a, a^* \varphi) $$ is bijective. Let's call this map $f$. In order to do this, we can define an inverse map $f^{-1}$ and show that for all morphisms $a : W \to \mathrm{Spec}B$, $f^{-1}(f(a)) = a$ and for all pairs $(\mu, \varphi)$, $f(f^{-1}((\mu, \varphi))) = (\mu, \varphi)$. What I don't understand is how to define the inverse map. Specifically, in the lemma I cited above, what is the map $f^*$ ($\mu^*$ in my notation) supposed to be?
As a follow up question, suppose we have a pair $(\mu : W \to \mathrm{Spec} A, \varphi: \mu^* \mathscr{B} \to \mathscr{O}_W)$. Then by adjunction we get $\varphi : \mathscr{B} \to \mu_* \mathscr{O}_W$. Evaluating this map of $\mathscr{O}_{\mathrm{Spec}A}$-algebras on global sections, we have an $A$-algebra homomorphism $B \to \Gamma(W, \mathscr{O}_W)$. This corresponds to a morphism of schemes $W \to \mathrm{Spec}(B)$. If we define the inverse to be this map, does the proof go through? I'm having some trouble showing the maps are mutually inverse.