Cook the spaghetti according to package instructions until al dente. Drain and set aside.
In a large skillet, heat the olive oil over medium heat. Add the minced garlic and cook for 1 minute until fragrant.
Add the chopped artichoke hearts and sun-dried tomatoes to the skillet. Cook for 3-4 minutes, stirring occasionally, until heated through.
If desired, add the red pepper flakes for a spicy kick. Season with salt and pepper to taste.
Add the cooked spaghetti to the skillet and toss to coat the pasta with the sauce. Cook for an additional 2-3 minutes until heated through.
Serve the spaghetti with grated Parmesan cheese and fresh basil on top. Enjoy!