The study of the structure and function of immune system components and their interactions with antigens.