Heat oven to 450 degrees Fahrenheit.
In a sauté pan over medium heat, add oil. When hot, add shallot and sauté until golden brown, approximately 4 to 5 minutes.
Add basil and spinach and cook, stirring, for one minute. Remove from heat and set aside.
In a food processor or blender, add beans, cream cheese, garlic, and stock. Puree until smooth.
Transfer bean mixture to a large bowl. Fold in shallot mixture, artichokes, ¼ cup parmesan, ¼ cup mozzarella, salt, pepper, and red chile flakes. Taste and add some lemon juice for a pop of acid if desired.
Spray 1-quart baking dish or casserole dish with oil spray and add mixture. Top with remaining ¼ cup parmesan and ¼ cup mozzarella.
Bake until bubbly and golden brown, approximately 20 to 25 minu