Heat the olive oil in a large saucepan or Dutch oven over medium-high heat.
Add the chopped leeks, sliced bell pepper, and red pepper flakes.
Sauté for 10 minutes, stirring occasionally, until the vegetables are tender and begin to brown.
Stir in the cannellini beans, vegetable broth, and minced garlic.
Reduce the heat to low, cover, and let it simmer for 5 minutes to allow the flavors to meld.
Season with salt and pepper, if desired.
Meanwhile, cook the spaghetti in a large pot of salted boiling water according to package directions until al dente, about 7-9 minutes.
Drain the pasta well.
To serve, divide the cooked spaghetti among 6 bowls. Generously spoon the chunky leek and bean sauce over each portion.
Finish by sprinkling with crumbled feta cheese, if using, and a scattering of toasted walnuts.