Heat the oil in a large pot or cast iron Dutch oven over medium heat. Add the onion and cook until translucent and lightly golden in color; add celery, carrots, and potato and continue to cook until vegetables start to become tender. Add garlic, tomatoes, kidney beans, broth, bay leaves, chili flakes (if using), and rosemary. Bring to a boil, reduce heat to low, and cover. Cook until vegetables reach desired tenderness – about 30 minutes – and then stir in spinach; cook for another 5 minutes, or until spinach is wilted. Add salt and pepper to taste and serve immediately. Top with Parmesan, if desired.