Place the rack in the middle of the oven and preheat it to 200 °C / 390 °F. Line a 20 cm x 25 cm (8-inch x 9-inch) deep baking dish with parchment paper with a few inches (or centimeters) of overhang off the sides.
Stir together the flour, brown sugar, ground almonds, and a pinch of salt in a bowl. Add the cold butter and rub the mixture between your fingers to get a sand-like texture. Add the milk and knead into a smooth batter. Divide the dough in half, wrap one half in clingfilm, and place in the freezer. Spread the other half evenly over the prepared baking dish. Place in the preheated oven and bake for 15 minutes at 200 °C / 390 °F. Once it bakes, remove it from the oven and set it aside for 5-10 minutes. Reduce the oven temperature to 180 °C / 350 °F.
Pour the majority (300ml) of milk into the saucepan. Place over medium heat and bring to a boil. Pour the rest of the milk (60ml) into a bowl. Add the vanilla custard powder and sugar. Using a whisk, stir to combine. While whisking, continuously pour the boiling hot milk into the custard mixture to mix. Then pour the mixture back into the saucepan and place over medium heat. Cook for 3 minutes for the mixture to cook. Stir regularly to prevent any lumps from forming. Remove from the heat and stir in the butter. Set aside for 5 minutes for the mixture to cool slightly, then stir in the egg yolk.
Peel the apples, remove the core and grate them into a bowl. Add the spices, brown sugar, cornstarch, and lemon juice. Stir to combine.
Spread the vanilla custard mixture over the baked and cooled dough. Spread the apple mixture over the custard mixture. Gently press the apple mixture toward the custard. Remove the dough from the freezer and grate it. Sprinkle over the apple mixture. Place in the preheated oven and bake for 45 minutes at 180 °C / 350 °F. Set aside for the dessert to cool, then cut into slices and serve. Optionally serve with a scoop of vanilla ice cream.