Put the almonds into a large skillet over medium heat. Gently toast the nuts, being careful not to let them burn, for about 3 minutes. Add 3 tablespoons olive oil, 1/2 teaspoon red chili flakes, 1 chopped garlic clove, and salt and pepper to taste. Cook for another 3 minutes and transfer to a plate to cool. Crush the almonds roughly and put them into a bowl along with the feta cheese, olives, and 1/3 of the basil leaves. Mix well to combine all the ingredients.
Put 3 tablespoons olive oil and the remaining 1/2 teaspoon chili flakes into the skillet over medium heat. Add the onions, remaining garlic, and 1/3 of the basil leaves and cook until the onions start to soften, about 5 minutes. Put in the eggplant and cook until it is soft, about 10 minutes, adding more olive oil if necessary. Add the zucchini, fresh tomatoes, and capers; season with salt and pepper. Continue cooking until these vegetables are soft but still whole. Add the canned tomatoes, vinegar, and remaining basil leaves. Continue to cook for another 15 minutes; remove from the heat and set aside to cool.
To serve, put the ratatouille into a bowl or platter and top with the feta, olive, and almond mixture.