Boil the spaghetti according to package directions. Strain them from the water.
Peel the onion and chop it finely. Saute it in half the butter. Add the mince and cook briefly.
Braise the flour in the rest of the butter. Add the milk in a thin trickle and stir nonstop until the sauce thickens. Season with salt and black pepper.
Pour some of the sauce into a suitable oven dish. Arrange a row of spaghetti. Pour the mince filling on top, pour on sauce and arrange another layer of spaghetti. Pour the rest of the sauce evenly on top.
Put the oven dish in a preheated oven and bake about 20 min.
Cut the tomatoes and mozzarella into round slices. Take the oven dish out and distribute the tomatoes and cheese on top. Finish baking for about another 10 min.
Sprinkle with basil.