This is a cross post from Stack Exchange. I should have posted it here in the first place.
I’m playing around with an architecture for a new suite of products using phx 1.3 and umbrella apps.
I have an existing Phoenix based enterprise class WebRTC soft phone (many keys, a display, multiple input and output audio device selection, and more). I have developed a Slack clone messaging app prototype with Phoenix. Both applications are fairly large I need to integrate the phone with the chat app into one front end that may be either just the phone, just the chat client, and both. I will need to add a lot of new features to the chat client moving forward I also want the architecture to support using the same client to provision additional setting on the call server (user based) and potentially a large number of admin level settings. I may also be adding other applications in the future like an operator panel, log viewer, and the list goes on… The client side JS is pretty simple, no front end framework. I render templates server side and push the html out over channels.
I would like to build this pluggable. Same endpoint and database. One common UX.
I think there will be two common apps in the umbrella, one for the Phoenix endpoint and a couple controllers and another for the main Repo and a couple schemas. I’m trying to figure out how difficult it will be to use two or more additional apps for each application. One for context and schema, another for controllers, views, templates, and brunch resource. Possibly another for 3rd party APIs.
To make this work, I’ll need a dynamic dispatch for routers in each of the apps. A method for handling migrations contained in each of the apps, and probably more that I have not thought of yet.
As anyone tried this? Are there any open source projects with a similar structure?
I have part of the solution for routing
defmodule PhxUmbrella.Web.Router do use PhxUmbrella.Web, :router # ... Application.get_env(:phx_umbrella_web, :routers) |> Enum.each(fn mod -> forward "/", mod end) end
This works in my spike project. However, I ran into a circular dependency issue on my main project. For the above to work, the main web app needs to have the other apps as dependencies. However, If I have APIs in the main web app that need to be exposed to the other apps, I would need to setup a dependency that way. Adding bidirectional deps in mix does not appear to work as I had suspected (mix deps.get) just hangs.
I’ll keep posting on this topic if I see people are interested. Your feedback and ideas are most welcome.