The animation has two phases. The dark phase in which no light is necessary and the light phase in which light is necessary. Initially no charge difference exists between the barrier junction. However because of the crystalline nature of Silicone electrons unbounded by a stable octet in the N layer have a tendency to migrate across the junction barrier to form a stable octet in the P layer. When this happens a difference in potential is set up between the two layers.
Electrons become excited when light quanta penetrates into the P layer.
The excited electrons have two choices of movement. They may migrate through the external circuit or short circuit there way across the barrier junction. If the photoelectric circuit is constructed correctly they will find their way back to the N junction through the external circuit. Animation of a Photovoltaic Circuit To better understand the workings of a solar cell it is necessary to understand the nature of a chemical bond. I have chosen Hydrogen and Helium to illustrate bonding.