When we wrote about resistors, we compared an electronic printed circuit board to a railway network. A diode is more like an escalator in a shopping mall going in one direction (unless we reverse the polarity). But we are getting ahead of ourselves. We should talk about the basics first, before the application.
The Basics of How a Diode Works

A diode is an inline electrical device with entry and exit terminals. It only permits electrical flow through it in one direction.
Well at least that is the theory, because infinite resistance is a hypothetical concept. Semiconductors made from silicon are the commonest diodes in use today.
If we interrupt battery-to-lamp circuits with diodes, the bulbs will either light, or not light depending on which terminal points to the power source.
If the arrangement allows electrons to flow, the diode is ‘forward based’, if not we speak of it as ‘backward’. Backward mistakes are a common cause of faults in school experiments.
Comparing Diode Electronics to Hydraulics

Comparing diodes with a one-way flow of water is another way to understand this principle. In hydraulics, a check valve allows water to flow in one direction in response to water pressure.
Thus, the hot water heater in your home allows cold water to top it up, but never sends it back. A diode works conceptually the same way, but this time under the ‘pressure’ of electricity.
Semiconductors are the ally of progress. We would not be able to convert alternating electricity to direct current without them. Nor would we have over-voltage protection, or binary logic gates in computing devices. We would also not have photovoltaic cells turning sunlight to solar energy. LED stands for light emitting diodes, and they are everywhere.
Related