bleeding at 7 weeks

Immie
So I had heavy bleeding a few days ago. This is my first so obviously I was literally having a breakdown, my boyfriend took me to the ER and by that time I had a clot. I was thinking the worst. But then came the ultrasound and there was my little bean with a heartbeat. 
So what caused me to bleed like that? It honestly was like my period was back..