Q:

What's the role of the transistor in this circuit?

So I have made this circuit for my project. (Instead of that variable resistor, I have used a single 1k ohm resistor)
I know that a transistor can work as a switch and amplifier, but in this circuit, what role is it playing? Please explain in detail? 
Thanks guys.

A:

Depending on the resistance of the LDR, the transitor may be viewed as either an amplifier or as a switch - and there is not a sharp transition between the two modes.
When the LDR is high resistance, the base current will be low, and the collector current will be base current times the transistor's gain (beta).  There will be significant voltage drop between the transistor's emitter and collector.
As more light hits the LDR, its resistance will drop, allowing more base current, and thus collector current.  At some point the collector current will become limited by the collector load (resistor and LED), so the transistor will be saturated, with only 0.2 volts or so between emitter and collector.
When we use a transistor as an amplifier, we keep the base current low enough that the transistor will not be saturated.
When we use a transistor as a switch, we want to have the transistor either cut off (no collector current), or saturated (current limited by load resistance).

