I thought this exact same thing a few months and have been building a framework that works exactly this way. I've spoken about it at a number of small meetups and events.
I haven't released it to the public yet, and it's currently getting a rewrite and bump to v2, but if you'd like to check it out i can send it over.