Generally speaking, the imperfect describes:
Ongoing events which haven't been completed yet E.g. J’étais à l’école – I was at school.
Repeated actions – non-specific number of times E.g. Je faisais le tennis chaque semaine – I used to do tennis every week.
General physical/ mental state of being E.g. J’aimais l’école – I liked school.
The perfect (or passé composé)
An event or action that took place in the past and has been completed Hier, j’ai été à l’école- Yesterday I was at school.
An action that was a one off or was completed a specific number of times La semaine dernière, j’ai fait le tennis tous les jours – Last week I did tennis everyday.
A change in general physical/ mental state of being En ce moment, j’ai aimé l’école – At that moment, I liked school.
The two work together: the imperfect describes what was happening, the perfect is used to interrupt. J’étais à l’école quand ma mère m’a appelé – I was at school when my mum called me.