Line a 12-cup cupcake pan with liners. Preheat the oven to 350°F/180°C.
Rub the lemon zest into the sugar until it looks like wet sand.
In a stand mixing bowl, whisk together the flour, lemon sugar, pistachios, baking powder, and salt. Mix in the butter on low speed for 3 minutes until it resembles coarse sand.
In a separate bowl, whisk together the sour cream, milk, oil, egg, vanilla extract, and lemon juice.
Mix the wets into the dries for a few seconds, then scrape down the bowl and continue mixing until just combined. Scoop into 12 cupcake liners, filling each one roughly ¾ full.
Bake for 15-20 minutes, or until a toothpick inserted comes out with a few moist crumbs attached. Let the pan cool on a wire rack for 5 minutes, then remove the cupcakes from the pan and let them continue cooling on the rack.
Make the raspberry filling. Cook the raspberries, sugar, and lemon juice over medium heat, mashing occasionally, until the filling is bright red and bubbly, about 10-12 minutes. Then mix in the whisked cornstarch and water. Cook 1-2 minutes longer until thickened.
Make the buttercream. Cream the butter until smooth, then mix in the powdered sugar. Once combined, mix in the heavy cream, lemon juice, and lemon zest. Continue beating until light and fluffy, 2-3 minutes longer.
Core the center of the cooled cupcakes and fill it with the raspberry compote. Pipe the lemon frosting around the core, then fill it with more raspberry filling. Garnish with chopped pistachios and fresh raspberries. Leave the cupcakes in the pan to core them. It’s easier to keep the cake intact, and you can remove them once cored. A piping bag with a large round tip is best used for the frosting!