  We introduce a new type of algebra, the Courant-Dorfman algebra. These are to
Courant algebroids what Lie-Rinehart algebras are to Lie algebroids, or Poisson
algebras to Poisson manifolds. We work with arbitrary rings and modules,
without any regularity, finiteness or non-degeneracy assumptions. To each
Courant-Dorfman algebra $(\R,\E)$ we associate a differential graded algebra
$\C(\E,\R)$ in a functorial way by means of explicit formulas. We describe two
canonical filtrations on $\C(\E,\R)$, and derive an analogue of the Cartan
relations for derivations of $\C(\E,\R)$; we classify central extensions of
$\E$ in terms of $H^2(\E,\R)$ and study the canonical cocycle
$\Theta\in\C^3(\E,\R)$ whose class $[\Theta]$ obstructs re-scalings of the
Courant-Dorfman structure. In the nondegenerate case, we also explicitly
describe the Poisson bracket on $\C(\E,\R)$; for Courant-Dorfman algebras
associated to Courant algebroids over finite-dimensional smooth manifolds, we
prove that the Poisson dg algebra $\C(\E,\R)$ is isomorphic to the one
constructed in \cite{Roy4-GrSymp} using graded manifolds.
