Grease a small baking tray 9x9 with ghee or line with parchment paper and spread the mixture into the tray and spread it evenly. Parchment paper is preferred as it makes it much easier to get the barfi out once it is set. Melt ghee in a pan over medium heat
Add the gram flour to the pan and roast at a low-medium temperature. The mixture clumps at first. After about 10 minutes it starts to loosen up. Keep stirring until the mixture smells nutty and has darkened slightly in color. Continue stirring to keep the mixture from sticking to the bottom of the pan and from burning. It will be done in about 20-25 minutes.
Turn off the flame. Continue stirring for 1-2 minutes more, as the pan is still hot and we don't want the flour to burn. Mix in the cardamom powder and give it a stir. Now let the besan cool down while we make the sugar syrup.
Add sugar and water to a pan. Heat on medium flame. You can also add a few strands of saffron.
Let the sugar dissolve, will take around 3-4 minutes. Then lower the heat and let syrup simmer for 6-7 minutes until it reaches one string consistency. You can also use a thermometer to check that the temperature is 222°F (or 106°C). Turn off the heat. Do not overcook the syrup once one string consistency is reached.
The besan mixture should be lukewarm by now. Add the sugar syrup immediately and mix well.
Transfer the mixture into the prepared tray and spread it evenly. Use a flat spatula to make it smooth on the top. And tap the tray on the counter couple of times to get the mixture to spread evenly. Garnish with thinly sliced almonds and pistachios.
Allow the barfi to settle for 2-3 hours. Depending on the weather, this can also take 4-6 hours.
When the besan barfi has set, cut into squares or diamond shapes using a sharp knife.