Physics and engineering design of the accelerator and electron dump for SPIDER