Heat the olive oil in a large pot over medium heat. Add the diced onion and minced garlic, sautéing until the onion becomes translucent.
Add the diced carrots and celery to the pot, cooking for an additional 5 minutes until they start to soften.
In the same pot, add the ground Italian sausage. Cook until the sausage is browned and cooked through, breaking it apart with a spoon.
Pour in the chicken or vegetable broth and diced tomatoes. Stir in the cannellini beans, kidney beans, oregano, basil, and red pepper flakes. Season with salt and black pepper.
Bring the soup to a boil, then reduce heat and let it simmer for about 15 minutes to allow the flavors to blend.
While the soup is simmering, cook the ditalini pasta or any small pasta according to package instructions. Drain and set aside.
Once the soup has simmered, add the cooked pasta and chopped spinach or kale. Stir well to combine, and cook for another 5 minutes until the greens are wilted.
Serve the soup hot, garnished with grated Parmesan cheese and fresh parsley if desired.
