We know that solar cells generate electricity by utilizing the energy of the photon,
This is an every day language, electricity. It means things electrical in general every day language.
but how does it generate electricity forever?
What is generated when the photons hit any material, is heat, and the sun's energy is at maximum 1300Watts per meter square at the top of the atmosphere ( from this atmospheric absorption and reflection must be subtracted), that leaves at maximum less than 1000watts/m^2 on the solar panel. That is the limit of how much energy can be extracted from the sun with any method, water heaters, conservatories and solar panels. So there can be no infinity in any variable, including electrical current from the solar panel.
In n-type terminal we have the bond of silicon and phosphorous so we have a free electron and when photons hit the panel they let the free electrons flow to the p-type terminal which is a bond of boron and silicon which has a free place for an electron
This is the microscopic picture .
but when all electrons move to the p-type from the n-type then how can they generate electricity forever when all electrons are at the p-type terminal? (because both the terminals are neutral)
If you get all the electrons on one side of an object the other side will be positive , and that will be it, no current flowing , just separated charges sitting there. There will be a finite electric field the value dependent on the geometries and the material.
If one closes the circuit, then the electrons can move to the positive side and the cycle can continue as long as photons fall from the sun. A current is created that is used for the "electricity" provided to the home.
The "sun an infinitely renewable source" is an exaggeration of scientific reporting, since the sun has a finite lifetime, except it is so large with respect to our lifetimes that it may be called infinite. The scientific expression should be "a continuously renewable source".