Is there a relation between Gelfand duality and the spectrum of a ring (with its Zariski topology)? Compare the following two results:

Thm A) Let $A$ be a commutative $C^*$-algebra and let $X$ be its Gelfand spectrum. Gelfand duality says that there's a natural isometric $*$-isomorphism from $A$ to $C(X)$, the $C^*$-algebra of continuous functions on $X$.


Thm B) Let $A$ be a commutative ring and $X=\operatorname{Spec}A$. There's a natural sheaf of rings $\mathscr{O}$ on $X$ such that $A=\Gamma(X,\mathscr{O})$.

Both theorems are very close. I wonder if it's possible to obtain theorem A as a particular case of theorem B, or a variant thereof.
 A: Yes, both Theorem A and Theorem B are special cases of a more general construction.
Denote by $R$ the category of commutative unital C*-algebras or the category of commutative rings.
Denote by $R'$ the full subcategory of $R$ given by reduced objects in $R$, meaning the only nilpotent element is zero.
(All commutative unital C*-algebras are reduced.)
Given an object $X∈R$, we can consider its poset $\def\Spec{\mathop{\sf Spec}}\Spec X$ of quotient objects (= subobjects in the opposite category) that belong to $R'$.
One can show that $\Spec X$ is a locale, the (localic) Zariski/Gelfand spectrum of $X$.
Furthermore, assuming the axiom of choice, this locale is spatial, so it corresponds to a topological space, namely, the traditional Zariski/Gelfand spectrum of $X$.
Given an open element $U$ of $\Spec X$ corresponding to a reduced quotient $X→Q$, its kernel $I⊂X$ is a radical ideal
and we can consider the localization $X[S^{-1}]∈R$,
defined using a universal property in the category $R$,
where $S=\{a∈X\mid I⊂\sqrt{(a)}\}$.
The assignment $$U↦X[S^{-1}]$$ defines a sheaf on $\Spec X$ valued in $R$.
This is precisely the structure sheaf of $\Spec X$
for both the Gelfand spectrum and the Zariski spectrum.
Of course, this construction is applicable to many other categories $R$:

*

*finitely presented entire functional calculus algebras, recovering the Stein duality for globally finitely presented Stein spaces (i.e., complex geometry).

*finitely generated germ-determined C^∞-rings, recovering the Dubuc duality for C^∞-loci (i.e., differential geometry);

*other dualities for algebraic geometry, such as formal schemes, etc.

*various versions of the above for derived geometry;

*Boolean algebras, recovering the Stone duality for compact totally disconnected Hausdorff spaces;

*complete Boolean algebras, recovering the Stonean duality for compact extremally disconnected Hausdorff spaces;

*localizable Boolean algebras, recovering the Gelfand-type duality for compact strictly localizable enhanced measurable spaces.

A: As @PaulTaylor said, the book Stone Spaces by Peter Johnstone has some stuff about this. I'll explain below, in my words, the parts that I found relevant.
Let $A$ be a commutative (unital) $C^*$-algebra. Its Gelfand spectrum $\operatorname{sp}(A)$ is usually defined as the set of nontrivial multiplicative linear functionals with the weak-$*$ topology. It's a well-known result that the map $\operatorname{sp}(A)\to\operatorname{Specm}(A)$, sending $\varphi$ to $\ker\varphi$ is a bijection.
In the case of $C^*$-algebras over $\mathbb{R}$, this book affirms that this map is actually a homeomorphism. (The cited function $\hat{a}$ is the one that sends a maximal ideal $\mathfrak{m}$ to the image of $a$ through $A\to A/\mathfrak{m}\cong\mathbb{R}$.)

(I tried to prove that the same holds for complex $C^*$-algebras without much success.)
Answering @YemonChoi comments: the cited book proves (theorem IV.4.10) that the functor $\operatorname{Specm}$ defines a duality between the category of compact Hausdorff spaces and the full subcategory of $\mathsf{CRing}$ whose objects are real $C^*$-algebras. Moreover, he proves an analogous result to the Gelfand duality in section V.3.8 using only the prime spectrum. But I have to say that I found it somewhat unsatisfying.
