The process begins with an electron gun that produces a high-energy electron beam. This beam is further accelerated using linear accelerators (linacs). Once the electrons reach the desired energy levels, they are directed into the undulator. The alternating magnetic fields in the undulator cause the electrons to oscillate, emitting X-rays in the process. These X-rays are then amplified through a process known as self-amplified spontaneous emission (SASE), resulting in extremely bright and coherent X-ray pulses.