In a conventional n-type DSSC, sunlight enters the cell through the transparent SnO:F top contact, striking the dye on the surface of the TiO. Photons striking the dye with enough energy to be absorbed create an excited state of the dye, from which an electron can be "injected" directly into the conduction band of the TiO. From there it moves by diffusion (as a result of an electron concentration gradient) to the clear anode on top.
Meanwhile, the dye molecule has lost an electron and the molecule will decompose if another electron is not provided. The dye strips one from iodide in electrolyte below the TiO, oxidizing it into triiodide. This reaction occurs quite quickly compared to the time that it takes for the injected electron to recombine with the oxidized dye molecule, preventing this recombination reaction that would effectively short-circuit the solar cell.
The triiodide then recovers its missing electron by mechanically diffusing to the bottom of the cell, where the counter electrode re-introduces the electrons after flowing through the external circuit.