  This paper gives a geometric interpretation of bordered Heegaard Floer
homology for manifolds with torus boundary. If $M$ is such a manifold, we show
that the type D structure $\widehat{\mathit{CFD}}$ may be viewed as a set of
immersed curves decorated with local systems in $\partial M$. These
curves-with-decoration are invariants of the underlying three-manifold up to
regular homotopy of the curves and isomorphism of the local systems. Given two
such manifolds and a homeomorphism $h$ between the boundary tori, the Heegaard
Floer homology of the closed manifold obtained by gluing with $h$ is obtained
from the Lagrangian intersection Floer homology of the curve-sets. This
machinery has several applications: We establish that the dimension of
$\widehat{\mathit{HF}}$ decreases under a certain class of degree one maps
(pinches) and we establish that the existence of an essential separating torus
gives rise to a lower bound on the dimension of $\widehat{\mathit{HF}}$. In
particular, it follows that a prime rational homology sphere $Y$ with
$\widehat{\mathit{HF}}(Y)<5$ must be geometric. Other results include a new
proof of Eftekhary's theorem that L-space homology spheres are atoroidal; a
complete characterisation of toroidal L-spaces in terms of gluing data; and a
proof of a conjecture of Hom, Lidman, and Vafaee on satellite L-space knots.
