I\'m trying to get a reasonable understanding of how one can build an app on top of ruby/rack (or even more ideally, an existing framework) that manages something equivalent
I think you've probably overcomplicated the situation somewhat. You can easily point different subdomains to different Rails applications using your web server configuration. For example in Nginx, you'd simply create different virtual hosts.
If you want all the modules contained in one application, then you can have a single virtual host with a wildcard subdomain, and use the routing in your Rails app to route via subdomain to different parts of your app. This would lend itself very well to an Engine architecture.
With regards databases, in the first example there's no problem at all as the different apps can handle their own database connections. With the engine example, typically engines tables would be in the same database but namespaced.
Edit - my answer is specifically talking about Rails, whereas your question was more generic.