There are multiple differences between the uses of imparfait and passé composé, perhaps the most important being that passé compose is used for singular events, whereas imparfait is used for past actions happening over time or past habits.
E.g. Hier, j'ai cuisiné une pizza (Yesterday, I cooked a pizza) versus Avant, je travaillais dans un restaurant italien (Before, I worked in an Italian restaurant)
Another difference is that imparfait is used for describing background, and passé composé is used for the action.
E.g. Je regardais la pluie à travers la fenêtre quand le téléphone a sonné (I was looking at the rain through the window when the telephone rang)