I'm trying to create for a Web App an MVC Architecture with a Hierarchical Router. The goal is manage all the business logic and views with a clear pattern.
Let me do some example:
- Route index called
- Index controller called; it has the responsibility to insert the view into the page.
Now the problems are:
How can I manage the required instance of model and collection or services? Where they must be stored? If I store they in the controller, how can they be accessible from external resources?
How can I manage all the UI Components that have not a dedicated route (like a login overlay callble everywhere) with their business logic and required objects instances?
I'm using React with Flux pattern. One solution i've found is to create the Controller without map them directly to the routes. This way let we use Controllers both into Routes handlers and from another Controller. In this case, how can we have the Controllers accessible from anywhere?
I know it depends on usage cases, but I'm trying to found a best practice ino order to have a clearly managing pattern.
Thanks in advance!