Heat the olive oil in a large sauce pan. Add the onions, celery, and bell pepper. Cook, stirring occasionally, until the vegetables are soft, about 10 minutes.
Stir in the garlic, cumin, chili powder, and red pepper flakes and cook until fragrant, about 30 seconds. Pour in the beans and stock and bring to a simmer over medium-high heat. Cook over medium heat, until the beans are tender, about 30 minutes.
Use an immersion blender to blend all or a portion of the soup, depending on your texture preference. I blended all the soup, but left it a little chunky.
Return the pureed soup to the pot, stir in lime juice, salt and pepper, to taste. Top with chopped cilantro and sliced avocado, if desired.