I don’t seem to get to the same relation between the angle \phi and \theta
I get \phi = \theta + \frac{\pi}{2} instead of \phi = \theta - \frac{\pi}{2}
Which seems correct if we look at this extreme example of the angles:
Where \theta = \frac{\pi}{4} and \phi = \frac{3\pi}{4}.
Which would give Bragg’s Law: \lambda = -2d_{hkl}sin(\theta).
So with a minus sign.
Negative \lambda is weird though
the minus sign disappears, so I think in fact \phi is the angle between -\mathbf{k} and \mathbf{G} (which is the acute angle next to the angle \phi in your drawing). I guess it should maybe be corrected to - \mathbf{k} \cdot \mathbf{G} = |\mathbf{k}| |\mathbf{G}| \cos(\phi) ?