Have you checked the alternator and the battery.
The alternator may have died and the battery may have only had enough to start it then sustain the engine for 5 mins.
Could be many reasons or a combination of them but alt and batt is where I'd start my checklist.
On another matter, I once bought a car that did the same as yours did.
The engine would not start afterwards.
After a long hard think, I wondered why the engine was so clean.
It turned out the seller ran a last minute degreaser job causing water to gather above the sparkies.
It was a simple matter of a blow out with a little denatured alcohol to get the car working fab.
Just added that to remind you some problems may seem really bad but can turn out to be really basic.
So don't get too disheartened at your new purchase.
Hope you get it all fixed buddy without too many dramas.