Slice the zucchini and eggplant thinly, about 3mm thick, and set aside.
Salt the eggplant slices generously and place them in a colander. Let sit for 15 minutes to draw out bitterness and moisture, then rinse and pat dry.
Preheat your oven to 180°C (350°F). Drizzle the sliced vegetables with olive oil, season with a little salt and pepper, and spread them on a baking sheet. Roast for 20-25 minutes until tender and slightly caramelized, then remove and let cool slightly.
Meanwhile, in a skillet, heat a tablespoon of olive oil over medium heat. Add the minced garlic and cook until fragrant, about 30 seconds, until it smells fragrant and slightly golden.
Add the chopped tomatoes to the skillet and simmer for 10-15 minutes until thickened and fragrant, stirring occasionally. Season with salt, pepper, and herbs if desired.
In a separate saucepan, melt butter or coconut oil over medium heat. Whisk in the flour and cook for about 1 minute, then gradually pour in the warm milk, whisking constantly to prevent lumps. Cook until the sauce thickens, about 5-7 minutes, then stir in a pinch of nutmeg and season with salt and pepper.
Layer the roasted vegetables in a baking dish, starting with a spoonful of tomato sauce, then overlapping slices of zucchini and eggplant. Repeat until all vegetables are layered, finishing with a layer of tomato sauce on top.
Pour the béchamel sauce evenly over the assembled layers, smoothing with the back of a spoon. Sprinkle with cheese if using.
Bake in the preheated oven for 30-35 minutes until bubbling and golden on top. Let rest for 10 minutes before slicing to allow it to set.
Slice into squares, serve warm, and enjoy this cozy, hearty dish with your favorite sides.