The formation and assembly of a typical star-forming galaxy at redshift z ≈ 3