Side view of a crystal: X-rays reflect from stacked lattice planes and add up only when the path difference is a whole number of wavelengths. Illustrative, textbook geometry.
The science
Bragg's law. Rays reflected from neighbouring planes spaced d apart differ in path by 2 d sin(theta); constructive interference needs 2 d sin(theta) = n lambda.
Pattern. N planes give the intensity I(theta) = sin^2(N delta/2) / sin^2(delta/2) with delta = 4 pi d sin(theta) / lambda, normalised so a peak equals N^2. More planes make the peaks narrower: the full width at half maximum in 2 theta is about 0.886 lambda / (N d cos(theta)) (the Scherrer relation).
Photon energy. E (keV) = 12.398 / lambda (Angstrom).
Simplifications. Kinematic (single-scattering) theory, point scatterers on perfect planes, no absorption, no atomic form factor or structure factor, no thermal motion. Not a structure-solving tool.