We develop a semi-analytic formalism for the determination of the evolution of the stellar mass accretion rate for specified density and velocity profiles that emerge from the runaway collapse of a prestellar cloud core. In the early phase, when the infall of matter from the surrounding envelope is substantial, the star accumulates mass primarily because of envelope-induced gravitational instability in a protostellar disc. In this phase, we model the envelope mass accretion rate from the isothermal free-fall collapse of a molecular cloud core. The disc gains mass from the envelope, and transports matter to the star via a disc accretion mechanism that includes episodic gravitational instability and mass accretion bursts according to the Toomre Q-criterion. In a later phase, mass is accreted on to the star due to gravitational torques within the spiral structures in the disc, in a manner that analytic theory suggests has a mass accretion rate ∝t−6/5. Our model provides a self-consistent evolution of the mass accretion rate by joining the spherical envelope accretion (dominant at the earlier stage) with the disc accretion (important at the later stage), and accounts for the presence of episodic accretion bursts at appropriate times. We show using a simple example that the burst mode can provide a good match to the observed distribution of bolometric luminosities. Our framework reproduces key elements of detailed numerical simulations of disc accretion and can aid in developing intuition about the basic physics as well as to compare theory with observations.