To make the base gravy, start with a cup of chopped onions. Either red or yellow can be used. Sauté them in 1/2 Tbsp of Oil until they turn translucent and slightly brown. This would take about 3-4 minutes. Cool and grind them to a fine paste.
Tip: In some gravies along with this, you can grind ginger, green chillies and garlic.
Simultaneously, blanch the tomatoes in a pot of water.
Tip: In the initial days of trying Indian cooking, chop the tomatoes, sauté them for few mins and then grind them separately. So that you will know the ratio. Once you get used to it, without chopping them up you will be able to eyeball the proper amount. Then you can just roughly chop and sauté them.
Next, in the same pan, add 1-1/2 to 2 Tbsp oil. Once the oil is hot, you can add the whole spices that a specific gravy calls for and let them sizzle. Then add the onion paste and keep sautéing until they turn golden brown and the raw flavour is gone.
This would take about 7-9 minutes on an electric range. For a gas range, it might be slightly less.
For a Muhal related dish, the onions have to be fried even more. Keep the flame in med to a med-high max. Do not keep it on high flame. It will get burnt. Keeping it at a constant heat helps them to get browned evenly.
Once the Onions are browned, add the tomato purée. Be careful while pouring this in the pan. They will bubble and splutter. In the first 5 minutes, you see it will be bubbling and steaming vigorously trying to lose much of the moisture content and getting reduced. In the next 5-6 minutes, the moisture would have evaporated almost and it will come together as a mass.Now if you see carefully on the sides of the concoction, small bubbles will appear and oil will be released. The below picture shows the stages of the masala getting cooked. The first pic is after 12-15 minutes. The second pic another 3 minutes after. The moisture would have evaporated and it will start to shrivel up. This is when we know the masala is completely cooked. This is what means "cook until the oil leaves / separate".
Now add the dry masalas that the specific gravy requires (3rd pic). Add the masalas and fry for few minutes. This is also essential as the dry spices' raw flavour must go and it should fry for few minutes. Then add some water and add the lentils or veggies according to the recipe and proceed.
If you are making this ahead and storing it for future use, do not add water. Turn off the stove once the masala is cooked (the stage before adding the dry masala). Cool it completely and freeze it.
Onion Tomato Base for Indian gravies https://www.themagicsaucepan.com/basics/until-oil-separates-cook-until-oil