  Using a recent strategy to encode the space of flat connections on a
three-manifold with string-like defects into the space of flat connections on a
so-called 2d Heegaard surface, we propose a novel way to define gauge invariant
bases for (3+1)d lattice gauge theories and gauge models of topological phases.
In particular, this method reconstructs the spin network basis and yields a
novel dual spin network basis. While the spin network basis allows to interpret
states in terms of electric excitations, on top of a vacuum sharply peaked on a
vanishing electric field, the dual spin network basis describes magnetic (or
curvature) excitations, on top of a vacuum sharply peaked on a vanishing
magnetic field (or flat connection). This technique is also applicable for
manifolds with boundaries. We distinguish in particular a dual pair of boundary
conditions, namely of electric type and of magnetic type. This can be used to
consider a generalization of Ocneanu's tube algebra in order to reveal the
algebraic structure of the excitations associated with certain 3d manifolds.
