We present the study of the star formation and central black hole activity of the galaxies in a sample of two nearby (z0.2) rich galaxy clusters (Abell 983 and 1731), targeted with unprecedented deep infrared Spitzer observations, near-IR imaging and optical spectroscopy. The extent of our observations covers the vast range of possible environments, from the dense cluster centre to the very rarefied cluster outskirts and accretion regions ( 3 virial radii). Thanks to the wavelength coverage of our observations, we are able to quantify both the obscured and unobscured star formation rates, as well as the presence of AGN. The star forming members of the two clusters present star formation rates compatible with values of coeval field galaxies. The 2D spatial distribution of the members is uniform in A983, whereas an elongated, filament-like, structure is clearly visible in A1731. The emerging picture is compatible with A983 being a fully evolved cluster, in contrast with the still actively accreting A1731. Approximately 50% of the galaxies in the filament-like structure in A1731 present a lower value of the specific star formation rate with respect to the remaining objects at a similar clustercentric distance. The suggested cause is on-going galaxy pre-processing along A1731s filament-like structure. In both clusters, the star forming and AGN fraction present a peak at 2 3 Mpc ( 1 1.5 r200 ) in clustercentric distance, decreasing towards the cluster cores. We compared the measured star formation rate and fraction of active central black holes with the ones derived from Illustris simulation. This simulation allowed us extend the analysis to a wider range of possible environment and redshift (z=0-4).The overall conclusion of our work confirms the dual effect of the cluster environment. Locally, it promotes gas instabilities, leading to the increase of the star formation and black hole activity; globally, it prevents further accretion of cold gas on the galaxies, that represents the fuel that powers both star formation and the accretion of the central black hole.