  We study the noncommutative modular curve (which was already studied by
Connes, Manin and Marcolli), and the space of geodesics on the usual modular
curve, from the viewpoint of algebraic groups, linear algebra and class field
theory. This allows us, first, to understand differently some aspects of
Manin's real multiplication program, and secondly, to study higher dimensional
analogs of the noncommutative modular curve, called irrational or
noncommutative boundaries of Shimura varieties. These are double cosets spaces
$L\backslash G(\mathbb{R})/P(K)$ where $G$ is a connected reductive algebraic
group over $\mathbb{Q}$, $L$ an arithmetic subgroup of $G(\mathbb{Q})$ and
$P(K)$ a real parabolic subgroup in $G(\R)$. We study three examples of these
general moduli spaces, and construct analogs of universal families for them.
These moduli spaces describe degenerations of complex structures on tori in
multifoliations, and contain important arithmetic information. Along the way,
we use noncommutative geometry ``\`a la Connes'' for some moduli
interpretations.
