  We give a presentation of the $n$-dimensional oriented cobordism category
$\text{Cob}_n$ with generators corresponding to diffeomorphisms and surgeries
along framed spheres, and a complete set of relations. Hence, given a functor
$F$ from the category of smooth oriented manifolds and diffeomorphisms to an
arbitrary category $C$, and morphisms induced by surgeries along framed
spheres, we obtain a necessary and sufficient set of relations these have to
satisfy to extend to a functor from $\text{Cob}_n$ to $C$. If $C$ is symmetric
and monoidal, then we also characterize when the extension is a TQFT.
  This framework is well-suited to defining natural cobordism maps in Heegaard
Floer homology. It also allows us to give a short proof of the classical
correspondence between (1+1)-dimensional TQFTs and commutative Frobenius
algebras. Finally, we use it to classify (2+1)-dimensional TQFTs in terms of
J-algebras, a new algebraic structure that consists of a split graded
involutive nearly Frobenius algebra endowed with a certain mapping class group
representation. This solves a long-standing open problem. As a corollary, we
obtain a structure theorem for (2+1)-dimensional TQFTs that assign a vector
space of the same dimension to every connected surface. We also note that there
are $2^{2^\omega}$ nonequivalent lax monoidal TQFTs over $\mathbb{C}$ that do
not extend to (1+1+1)-dimensional ones.
