Line a 12-cup cupcake pan with paper liners and preheat your oven to 350°F (180°C). Gather all your ingredients, ensuring the butter, sour cream, milk, and egg are at room temperature for the best results.
Rub the lemon zest into the white sugar with your fingers until it resembles wet sand. In a stand mixer bowl, whisk together the cake flour, lemon sugar (sugar mixed with zest), finely chopped pistachios, baking powder, and sea salt. Add the cubed butter and mix on low speed for about 3 minutes, until the mixture looks like coarse sand. In a separate bowl, whisk together the sour cream, whole milk, vegetable oil, egg, vanilla extract, and fresh lemon juice. Gradually mix the wet ingredients into the dry mixture, scraping down the sides, and continue mixing until just combined. Scoop the batter into the cupcake liners, filling each about 3/4 full. I always find using an ice cream scoop makes this step tidier and ensures even cupcakes.
Bake the cupcakes in the preheated oven for 15-20 minutes, or until a toothpick inserted into the center comes out with a few moist crumbs attached. Allow the pan to cool on a wire rack for 5 minutes. Then remove the cupcakes from the pan and let them continue to cool completely on the rack.
To make the raspberry compote filling, combine the raspberries, white sugar, and fresh lemon juice in a saucepan over medium heat. Mash the raspberries occasionally as they cook, until the mixture is bright red and bubbly, about 10-12 minutes. Whisk together the cornstarch and water, then stir this mixture into the raspberries. Cook for another 1-2 minutes until the filling thickens, then let cool completely before using. I like to taste the compote here and adjust the lemon juice if I want it a bit tangier.
Cream the room-temperature butter using a mixer until smooth and creamy. Gradually beat in the powdered sugar. Once it's well incorporated, add the heavy cream, lemon juice, and lemon zest. Continue beating the mixture until it's light and fluffy, about 2-3 minutes. For a more authentic flavor, I like to use freshly squeezed lemon juice and zest at this point.
Once the cupcakes are completely cooled, leave them in the pan and carefully core out the centers using a small knife or a cupcake corer. Fill each cavity with the cooled raspberry compote from Step 4. Pipe the lemon frosting from Step 5 around the core on top of each cupcake, then add a little more raspberry filling into the center. Garnish each cupcake with chopped pistachios and fresh raspberries. It's easier to core cupcakes while they're still in the pan—it helps keep the cake intact.