Adjust an oven rack to the centre position and preheat to 150C.
To make the soup, melt the oil in a large casserole over medium-high heat. When the oil shimmers, add the shallots, ginger, pieces of lemongrass, and a generous pinch of salt. Reduce the heat to low and cook, stirring occasionally, until the shallots are tender and just starting to brown, about 18 minutes.
Increase the heat to high and add the carrots, coconut milk, curry paste, fish sauce, and 720ml of the stock. As the soup comes to a boil, partially cover the pot and reduce the heat to keep the liquid at a gentle simmer. Cook the soup until the carrots are completely tender, about 25 minutes.
Meanwhile, to make the garnish, in a medium bowl, combine the peanuts, coconut flakes, fish sauce, chillies, oil, lemongrass, sugar, and lime leaves (if using). Spread the mixture out on a baking tray in a single layer. Bake until the coconut is a deep golden brown, 18 to 20 minutes, stirring every 3 minutes after the first 10 minutes. Remove from the oven and pour the mixture immediately into a bowl to prevent overcooking. Stir to combine and set aside.
Remove the soup from the heat and discard the lemongrass. Use an immersion blender to purée the soup. (Alternatively, transfer soup in batches to a blender or food processor and purée.) Taste and adjust for salt and curry paste. Add more stock or water to thin soup to the desired consistency.
Thinly slice the Thai basil leaves and arrange on a small plate or platter, along with lime wedges and the peanut mixture. Serve the soup hot with garnishes.
