To gain insight into the nitrogen-related gas-surface reaction dynamics on carbon-based thermal protection systems of hypersonic vehicles, we have investigated the adsorption, diffusion, and reactions of atomic nitrogen, N(S-4), on the (0001) face of graphite using periodic density functional theory with a dispersion corrected functional. The atomic nitrogen is found to bind with pristine graphite at a bridge site, with a barrier of 0.88 eV for diffusing to an adjacent bridge site. Its adsorption energy at defect sites is significantly higher, while that between graphene layers is lower. The formation of N-2 via Langmuir-Hinshelwood (LH) and Eley-Rideal (ER) mechanisms was also investigated. In the LH pathway, the recombinative desorption of N-2 proceeds via a transition state with a relatively low barrier (0.53 eV). In addition, there is a metastable surface species, which is capable of trapping the nascent N-2 at low surface temperatures as a result of the large energy disposal into the N-N vibration. The desorbed N-2 is highly excited in both of its translational and vibrational degrees of freedom. The ER reaction is direct and fast, and it also leads to translationally and internally excited N-2. Finally, the formation of CN from a defect site is calculated to be endoergic by 2.75 eV. These results are used to rationalize the results of recent molecular beam experiments.