In a large pot of boiling water, blanch green beans. Remove to an ice bath until cool, drain and let dry. Lightly butter a 13 by 9 by 2-inch glass baking dish.
In a large frying pan, over medium-high heat, saute bacon until lightly crispy, remove bacon to a paper towel lined plate to drain. In remaining bacon fat, add 1 tablespoon olive oil, heat over medium-high heat, add onions and saute until just starting to caramelize, add in red bell peppers, saute 2 minutes, add in mushrooms and minced shallot and saute for 2 more minutes. Season with the salt, pepper and cayenne. Set aside.
For the Roux:
In a medium saucepan over medium heat, melt butter. When butter is melted, add in flour, all at once and stir vigorously with a wooden spoon until well combined. Continue to stir for 1 minute more. Add in milk 1/2 cup at first, stirring well to combine, then add 1 cup more milk, stir to combine and bring to a simmer, then add final 1/2 cup of milk and stir and simmer until thickened.
Add in seasonings, combine with green bean mixture and pour into prepared pan. Top with 1 1/2 cups panko crumbs, then reserved bacon, then remainder of panko lightly sprinkled on top.
Place in oven, set timer for 35 minutes.
For the Topping:
In a medium bowl place buttermilk, onion, and shallots. Let sit 10 minutes, drain well.
In a medium bowl, combine flour and seasonings. When green beans have been in the oven 25 minutes, in a large frying pan, heat canola oil to 350 degrees F. While oil is heating, dredge drained onion and shallots in flour mixture. Drop carefully into the hot oil, 1/3 at a time. They will cook rapidly, 1 minute or less. Turn over if necessary. Remove and drain on paper towels. Let oil heat between batches.
When timer goes off for green beans, take out of oven, top with onion-shallot mixture, evenly coating the casserole, place back into oven and continue to cook for 5 more minutes. Remove and let set 5 minutes before serving.