Preheat the oven to 375°F (190°C).
Cut the zucchini in half lengthwise and scoop out the center with a spoon to create boats. Set aside the scooped-out flesh.
In a large skillet over medium heat, add olive oil. Once hot, add the minced garlic and diced mushrooms and sauté for about 3-4 minutes or until the mushrooms are soft.
Add the chopped spinach to the skillet and cook for another 2-3 minutes until wilted. Remove from heat.
In a mixing bowl, combine the cooked mushroom and spinach mixture with ricotta cheese, salt, black pepper, and crushed red pepper flakes (if using).
Spoon the filling generously into each zucchini boat and place them in the baking dish.
Sprinkle shredded mozzarella and grated Parmesan cheese on top of the stuffed zucchini.
Cover the baking dish with foil and bake in the preheated oven for 20 minutes.
After 20 minutes, remove the foil and bake for an additional 5 minutes or until the cheese is bubbly and lightly golden.
Remove from the oven, let cool slightly, and garnish with fresh basil leaves if desired before serving.