Representation theory of SU(2) and SU(3) with applications to spin and quark models