A future compact and modular X and gamma-ray spectrometer (XGS) has been designed and a series of prototypes have been developed and tested. The experiment envisages the use of CsI scintillator bars read out at both ends by single-cell 25 mm2 Silicon Drift Detectors. Digital algorithms are used to discriminate between events absorbed in the Silicon layer (lower energy X rays) and events absorbed in the scintillator crystal (higher energy X rays and gamma-rays). The prototype characterization is shown and the modular design for future experiments with possible astrophysical applications (e.g. for the THESEUS mission proposed for the ESA M5 call) are discussed.