Grate the zucchini using the coarse side of a box grater.
Heat the olive oil in a large skillet over medium heat.
Add the onion (or shallots) and cook for 4–5 minutes until softened.
Stir in the garlic and cook for another 30 seconds.
Add the grated zucchini and season with salt, pepper, and Italian seasoning if using.
Cook over medium heat for 15–18 minutes, stirring occasionally, until the zucchini becomes very soft and most of its moisture has evaporated.
It should look jammy rather than watery.
Meanwhile, bring a large pot of generously salted water to a boil. Cook the pasta until al dente according to the package directions. Before draining, reserve at least 1 cup (240 ml) of the pasta cooking water.
Add about 1/4 cup (60 ml) of the reserved pasta water and stir to loosen the zucchini mixture.
Add the drained pasta to the skillet. Sprinkle in the Parmesan, lemon zest, and lemon juice.
Toss continuously, adding more reserved pasta water a little at a time, until the cheese melts and forms a smooth, glossy sauce that coats the pasta.
Taste and adjust the seasoning with additional salt, pepper, or lemon juice if needed.
Serve immediately, topped with extra Parmesan, fresh basil, lemon slices and a pinch of red pepper flakes, if desired.