Can someone explain this schematic and how to modify it to add PWM LED dimming?
Many things are possible. 

Whether it is easy to do or worthwhile is another question.

First, a warning:

That circuit is not isolated - you must assume that all parts are at line voltage, and can therefore kill you or anything you attach to it. 

You must either isolate your control circuit or else build it so that it will work properly without being isolated - in which case your control circuit must be fully enclosed such that it can't be touched when it is connected to power.



The 9918c doesn't appear to have provision for dimming.

Here's a more informative datasheet (in Chinese, but the interesting bits can be made out from the formulas and designators.  Thanks to @SpehroPefhany.



From the circuit, I'd say you really only have two possibilities:


Open the connection from C2 to R2.  That's the DC supply for the light.
Open the CS (current set) connection.


Either one should shut off the light.

If you then pulse the connections (through an appropriate transistor) then you should be able to get a dimmed light.

Either way you go, you will need a switching element that can withstand  at least 400 VDC, and which can conduct at least 100mA.  Those ratings are the minimum, but may need to be higher.



The 9918C is a constant current regulator.  The resistors from CS to GND set the current.

The current through Drain, through the resistors, to GND will be constant over a wide range of voltages.

B1 is a bridge rectifier.  It makes (pulsing) DC out of the AC line voltage.

C1, C2, R1, and L1 form a filter to clean up the DC and make it nice and smooth - this helps eliminate flickering at line frequency.

The 9818c seems to regulate the current by switching on and off quickly (it is a switch mode regulator.)  

What you have marked as TR1 is actually an inductor, and is part of the regulator.

D1 is also part of the regulator.   It is there to catch the reverse voltage spikes that occur when the current through the inductor is switched on and off.

R2 provides current to the 9918 to get it going.  Once it starts operating, it gets current through C4 and the inductor.

C4 also helps to smooth the regulated DC.  The 9918 regulates the current in pulses.  Without C4, the light would flicker at whatever frequency is needed to maintain the desired current for the current combination of voltage and LED operation (forward voltage of LEDs depends on temperature and other things, which change how much current flows.)

Current through the sense resistors causes a voltage to appear on CS.  The 9918 compares the voltage to an internal reference voltage.  If the CS voltage is higher, then it turns off the current.  If it is lower, then it turns on the current.  This causes the current to flow in pulses.