In modular curves and modular forms, there is an adelic formulation, in which smaller open subgroups of some adelic group relate to higher level structure. As we know, higher level structure corresponds to higher torsion points (when we say "higher" we mean, e.g., $E[n]$ is "higher" than $E[m]$ if $m \mid n$). In complex multiplication, higher torsion points correspond to higher ray class fields, which correspond to smaller open subgroups of the ideles of the field of complex multiplication in question! (\*Since someone asked, I sketch this in more detail below)


Thus I would like to ask whether there is a formulation that combines the adelic formulation of complex multiplication with the adelic formulation of modular curves.


To simplify and thus explain the principles\*\*, it would be best to work with elliptic curves with complex multiplication. Let $F$ be a quadratic imaginary field. 


Then I have the following guess for an idea: We have an injection from the ideles of $F$ into the rational adelic points of $\mathrm{GL}\_2$, and after quotienting by the rational (i.e. non-adelic) points, we still have a nice inclusion? I would guess that the resulting points at those corresponding to CM elliptic curves and their level structures, but I don't entirely understand how to prove this.


Furthermore, assuming this is true, what does this say about the Galois action? Does this allow us to construct the Galois action (i.e. rational structure) on modular curves?


(Also, to be even more precise, we should let the ideles of $F$ be represented by the adelic points of the Weil restriction of $G\_m$ from $F$ to $\mathbb{Q}$).


\*In the adelic formulation of modular curves, we view modular curves as quotients of the adelic points of $GL\_2$. We get different modular curves, e.g. $\Gamma(N)$ instead of $\Gamma(M)$ (for $M,N$ some positive integers) by considering different open subgroups of the adeles. As is well-known, $\Gamma(N)$ parametrizes elliptic curves with "level N" structure, meaning pairs consisting of elliptic curves and $N$-torsion points. In complex multiplication, the $N$-torsion points correspond to the ray class field of level $N$, and this is, in particular, done through an adelic formulation of the main theorem of complex multiplication.


\*\*Though I assume everything will extend to higher-dimensional Shimura varieties in an analogous way.



Adelic formulations of complex multiplication and modular curves
This is an expansion of my comment above: You can view the modular curve of level $K$ over $\mathbb{C}$ as the double coset space
$$GL\_2(\mathbb{Q})\backslash\mathbb{H}^{\pm}\times GL\_2(\mathbb{A}\_f)/K.$$
Here, $\mathbb{H}^{\pm}$ is the union of the half planes. This set is in bijection with isogeny classes of elliptic curves over $\mathbb{C}$ with $K$-level structure, and the bijection is obtained as follows: A point $\tau\in\mathbb{H}^{\pm}$ gives us an isomorphism of vector spaces $\mathbb{R}^2\xrightarrow{\simeq}\mathbb{C}$, which in turn equips $\mathbb{Q}^2$ with a Hodge structure of weights $(0,-1),(-1,0)$. This allows us to interpret it as the $\mathbb{Q}$-homology of an elliptic curve $E\_{\tau}$ (This is just a fancier way of saying that $E\_{\tau}=\mathbb{C}/(\mathbb{Z}+\mathbb{Z}\tau)$). So, given a point $[(\tau,g)]$ in the double coset space, we attach to it the elliptic curve (up to isogeny) $E\_{\tau}$, with the $K$-level structure given by the $K$-orbit of the isomorphism
$$\mathbb{A}\_f^2\xrightarrow{g}\mathbb{A}\_f^2= H\_1(E\_{\tau},\mathbb{A}\_f).$$


Let $\alpha$ be some generator of $F$ over $\mathbb{Q}$: it allows us to identify $F$ with $\mathbb{Q}^2$. Choose an embedding $F$ in $\mathbb{C}$, so that $\alpha$ can be viewed as an element of $\mathbb{H}$. Let $H$ be the rank $2$ torus over $\mathbb{Q}$ attached to $F$: we can view it as the sub-group of $GL\_2$ that commutes with the action of $F$. We then get a map 
$$\eta:H(\mathbb{Q})\backslash H(\mathbb{A}\_f)\rightarrow GL\_2(\mathbb{Q})\backslash\mathbb{H}^{\pm}\times GL\_2(\mathbb{A}\_f)/K$$
$$\;\;\;\;[h]\mapsto [(\alpha,h)].$$
The image of this map consists exactly of those elliptic curves admitting CM by $F$, whose level structures admit an $F$-equivariant representative. (One subtlety is that, if $E$ is an elliptic curve in the image, then you can also look at the curve $\overline{E}$, where you twist the action of $F$ by complex conjugation. This won't show up in the image of $\eta$).


Now, we have the global reciprocity isomorphism
$$Gal(\overline{F}/F)^{ab}\xrightarrow{\simeq}H(\mathbb{Q}\backslash H(\mathbb{A}\_f),$$
which equips $H(\mathbb{Q})\backslash H(\mathbb{A}\_f)$ with the structure of a pro-finite $Gal(\overline{F}/F)$-set. The main theorem of CM for elliptic curves says that, if we identify the right hand side of $\eta$ with the set of $\overline{\mathbb{Q}}$-points of the modular curve, then $\eta$ is in fact Galois-equivariant. 


There is a slight sign issue here, since there are two possible choices for the reciprocity map (arithmetic or geometric Frobenius), but this is the general shape.


