This talk will introduce generalized Jordan–Wigner transformation on arbitrary triangulation of any simply connected manifold in 2d, 3d and general dimensions. This gives a duality between all fermionic systems and a new class of lattice gauge theories. This map preserves the locality and has an explicit dependence on the second Stiefel–Whitney class and a choice of spin structure on the manifold. In the spacetime picture, this mapping is exactly equivalent to introducing topological terms (Chern-Simon term in 2d or the Steenrod square term in general) to the Euclidean action. We can increase the code distance of this mapping, such that this mapping can correct all 1-qubit and 2-qubits errors on 2d square lattice, which is useful for the simulation of fermions on the quantum computer. I will also show how this duality is useful in the construction of fermionic symmetry protected topological phases.