help - recent unexpected breakup

Just recently unexpectedly got broken up with by boyfriend and not dealing very well. Everything seemed to be going fine and he kept telling me he was happy in the relationship and all of a sudden I get back from holiday and he breaks up with me. Tells me he's been feeling that way for weeks and needs some space to sort something out, but we can still be friends and potentially get back together. His close friend later tells me he has no interest in getting back together and barely any in being friends and the reason he broke up with me was he needed to sort something out and no longer loved me. Which is fine just that was all I was told and no further explanation, also not even directly from him. How does something go from seeming to be going so well to suddenly falling to shit? How do I cope?