Here is a draft architecture that I have been working with for CLI applications. It is not complete because it has some holes in it. The whole idea is that it is built will layers each of which enjoys the services of the layers below it. Personally, I think there should not be more than seven (7) layers but here I only make use of five (5). The curved arrows imply that failures are reported immediately without having to dig into the layers below. I plan to refine this over time but this is the first stab.