This is the basic dark and light sensor which using photoresistor as sensing component.
The transistor act like as a switch, when the “switch” in on condition then the relay will be activated.
The potensiometer adjust the trigger ‘on’ level. The diode in the circuit diagram shows to be 1N914. This is ok if you have a light-duty relay, also the 1N914 is a signal diode so actually does not qualify. Use a 1N4001 (or better) instead. A couple of substitutes for the 2N2222 transistor are: NTE123A, ECG123A, PN100, etc.