Explaining transistor schematic
The device in question is meant to be used with a bidirectional digital pin. Setting the pin to a high output discharges the capacitor, resetting the circuit. Realize that the capacitor "discharges" high and "charges" low since it is tied to VCC rather than ground.

In order to make a measurement, the pin is switched to an input. When the transistor is triggered, the capacitor charges low at a speed governed by how activated the transistor is via the reflection of the diode off a surface. Since the software knows when it changed the output to an input and it can detect when the input goes low, it can use this timing to sense how reflective the surface is.