Let $C$ be the curve $x^2+y^2-1$, defined over $\mathbb R$. It is easy to see that $\mathbb R[C]$ is not a UFD, as witnessed by the identity $(1-x)(1+x)=y^2$. On the other hand, the real locus $C(\mathbb R)$ is a circle, which is not smply connected.


I'm then wondering if there is some more general connection between the fundamental group of $C(\mathbb R)$ and the class group of $\mathbb R[C]$. I vaguely heard that the class group of a number field can be thought of as its fundamental group (though I don't understand the details). Can this analogy be carried over to function fields?



UFD and fundamental group
It's the absolute Galois group that can be thought of as a fundamental group, since it is the [étale fundamental group](http://en.wikipedia.org/wiki/%C3%89tale_fundamental_group) of $\text{Spec } K$. The ideal class group is instead a [Picard group](http://en.wikipedia.org/wiki/Picard_group) of line bundles, which for topological spaces and real line bundles is the cohomology group 


$$H^1(X, \mathbb{G}\_m(\mathbb{R})) \cong H^1(X, \mathbb{Z}\_2)$$ 


and which for varieties is the [étale cohomology](http://en.wikipedia.org/wiki/%C3%89tale_cohomology) group $H^1(X, \mathbb{G}\_m)$ (here we need $X = \text{Spec } \mathcal{O}\_K$). In fact the [Serre-Swan theorem](http://en.wikipedia.org/wiki/Serre%E2%80%93Swan_theorem) implies that if $X$ is a smooth manifold then the algebraic Picard group of $C^{\infty}(X)$, defined in terms of invertible modules, is the smooth Picard group $H^1(X, \mathbb{Z}\_2)$ of real line bundles on $X$. That's why you aren't surprised to get a group of order $2$ when $X$ is the circle, as KConrad says in the comments. 


(But don't expect the relationship between the topology of the real points of a curve over $\mathbb{R}$ and the Picard group of its ring of functions to be this nice in general. For example, sometimes there may not be any real points. You should instead be looking, at the very least, at the complex points together with the action of complex conjugation on them.) 


[Here](https://qchu.wordpress.com/2014/10/19/the-picard-groups/) is an attempt I made to sort all this out in more detail. 


