This paper presents a self-consistent model for the evolution of gas produced in the debris disc of $beta$ Pictoris. Our model proposes that atomic carbon and oxygen are created from the photodissociation of CO, which is itself released from volatile-rich bodies in the debris disc due to grain-grain collisions or photodesorption. While the CO lasts less than one orbit, the atomic gas evolves by viscous spreading resulting in an accretion disc inside the parent belt and a decretion disc outside. The temperature, ionisation fraction and population levels of carbon and oxygen are followed with the photodissociation region model Cloudy, which is coupled to a dynamical viscous $alpha$ model. We present new gas observations of $beta$ Pic, of C I observed with APEX and O I observed with Herschel, and show that these along with published C II and CO observations can all be explained with this new model. Our model requires a viscosity $alpha$ > 0.1, similar to that found in sufficiently ionised discs of other astronomical objects; we propose that the magnetorotational instability is at play in this highly ionised and dilute medium. This new model can be tested from its predictions for high resolution ALMA observations of C I. We also constrain the water content of the planetesimals in $beta$ Pic. The scenario proposed here might be at play in all debris discs and this model could be used more generally on all discs with C, O or CO detections.