Start by slicing the onions. Tips for julienne style slicing: cut off the ends, cut in half, then slice each half with the flat side down on the cutting board. Go for thinner slices.
Heat olive oil in a large skillet on medium-high heat until it begins to shimmer.
Add the sliced onions and toss to coat. Sprinkle with 1-2 pinches of kosher salt and toss again.
Let the onions cook, undisturbed, until they begin to develop some color, about 3-5 minutes. Then, mix well, and leave the onions to cook again, undisturbed, for another 3-5 minutes. Repeat 2-3 times until the onions are nice and evenly browned. Reduce the heat to low and cook the onions for another 15 minutes or so, until they are soft, melted, and a deep brown. Remove from the heat and set aside.
Prepare/ boil the pasta according to box instructions.
While the pasta is cooking, juice and zest the lemon and set aside.
When the pasta is ready, add a tablespoon of olive oil to a large skillet over medium heat. Once hot, add the garlic and cook until fragrant, about 1 minute.
Add the cooked pasta to the skillet with the garlic and toss to coat. Add salt and pepper to taste.
Add in the ricotta and the parmesan cheese, and mix well. Add in the lemon juice and half the zest and mix again. If the sauce seems too dry and clumpy, add in some of the reserved pasta water to loosen it up and make it more creamy.
Once everything has come together, add the caramelized onions and mix. You can also use the onions as a garnish rather than mixing them into the pasta.
Serve hot. Garnish with the rest of the lemon zest, fresh basil, and chili flakes.