Working of a Diode
To understand how a pn-junction diode works, begin by imagining two separate bits of semiconductor, one n-type, the other p-type.
Bring them together and join them to make one piece of semiconductor which is doped differently either side of the junction.
Free electrons on the n-side and free holes on the p-side can initially wander across the junction. When a free electron meets a free hole it can 'drop into it'. So far as charge movements are concerned this means the hole and electron cancel each other and vanish.
As a result, the free electrons and holes near the junction tend to eat each other, producing a region depleted of any moving charges. This creates what is called the depletion zone.
Now, any free charge which wanders into the depletion zone finds itself in a region with no other free charges. Locally it sees a lot of positive charges (the donor atoms) on the n-type side and a lot of negative charges (the acceptor atoms) on the p-type side. These exert a force on the free charge, driving it back to its 'own side' of the junction away from the depletion zone.
The acceptor and donor atoms are 'nailed down' in the solid and cannot move around. However, the negative charge of the acceptor's extra electron and the positive charge of the donor's extra proton (exposed by it's missing electron) tend to keep the depletion zone swept clean of free charges once the zone has formed. A free charge now requires some extra energy to overcome the forces from the donor/acceptor atoms to be able to cross the zone. The junction therefore acts like a barrier, blocking any charge flow (current) across the barrier.
Usually, we represent this barrier by 'bending' the conduction and valence bands as they cross the depletion zone. Now we can imagine the electrons having to 'get uphill' to move from the n-type side to the p-type side. For simplicity we tend to not bother with drawing the actual donor and acceptor atoms which are causing this effect!
The holes behave a bit like balloons bobbing up against a ceiling. On this kind of diagram you require energy to 'pull them down' before they can move from the p-type side to the n-type side. The energy required by the free holes and electrons can be supplied by a suitable voltage applied between the two ends of the pn-junction diode. Notice that this voltage must be supplied the correct way around, this pushes the charges over the barrier. However, applying the voltage the 'wrong' way around makes things worse by pulling what free charges there are away from the junction!
This is why diodes conduct in one direction but not the other.