  We study rational curves on smooth complex Calabi--Yau threefolds via
noncommutative algebra. By the general theory of derived noncommutative
deformations due to Efimov, Lunts and Orlov, the structure sheaf of a rational
curve in a smooth CY 3-fold $Y$ is pro-represented by a nonpositively graded dg
algebra $\Gamma$. The curve is called nc rigid if $H^0\Gamma$ is finite
dimensional. When $C$ is contractible, $H^0\Gamma$ is isomorphic to the
contraction algebra defined by Donovan and Wemyss. More generally, one can show
that there exists a $\Gamma$ pro-representing the (derived) multi-pointed
deformation (defined by Kawamata) of a collection of rational curves
$C_1,\ldots,C_t$ so that
${\mathrm{dim}}({\rm{Hom}}_Y({\mathcal{O}}_{C_i},{\mathcal{O}}_{C_j}))=\delta_{ij}$.
The collection is called nc rigid if $H^0\Gamma$ is finite dimensional. We
prove that $\Gamma$ is a homologically smooth bimodule 3CY algebra. As a
consequence, we define a (2CY) cluster category ${\mathcal{C}}_\Gamma$ for such
a collection of rational curves in $Y$. It has finite-dimensional morphism
spaces iff the collection is nc rigid. When $\bigcup_{i=1}^tC_i$ is (formally)
contractible by a morphism $\hat{Y}\to \hat{X}$, ${\mathcal{C}}_\Gamma$ is
equivalent to the singularity category of $\hat{X}$ and thus categorifies the
contraction algebra of Donovan and Wemyss. The Calabi-Yau structure on $Y$
determines a canonical class $[w]$ (defined up to right equivalence) in the
zeroth Hochschild homology of $H^0\Gamma$. Using our previous work on the
noncommutative Mather--Yau theorem and singular Hochschild cohomology, we prove
that the singularities underlying a 3-dimensional smooth flopping contraction
are classified by the derived equivalence class of the pair $(H^0\Gamma, [w])$.
We also give a new necessary condition for contractibility of rational curves
in terms of $\Gamma$.
