Umbrella app, feedback on planned code separation


I have not started to code umbrella yet. But I have some user functionality/logic, front end logic with user authentication, and admin logic planned and I was thinking of separating it into three separate umbrella apps (one for each).

From this thread: Questions about Umbrella apps

It seems like umbrella app runs on separate ports by default.

So maybe I should just keep the front end and login user deal within the same umbrella app or just deal with some port forwarding base on route but that’s seem messy. I think for sure I’d like to separate the admin logic into its separate umbrella app. Does this make any sense? Or is there anything I’m missing.

Any opinion is appreciated.


I have similar questions.

It seems umbrella apps might provide the benefits of monolith and microservices for medium sized projects with smaller teams, with fewer downsides than either.

But it’s tough to find definitive best practices answer tutorials.

1 Like

It depends how you want to organize apps. For example, you may have one app to run phoenix and use other modules in several ways.

  • Example 1: one phoenix “app” + context/domain apps
    • The main phoenix app handles all web interaction (e.g. controller)
    • Actual behaviors are delegated to modules in other apps: e.g. Admin.Posts
    • Individual app has smaller responsibility (e.g. web input validation and sanitization should happen on web app, not context/domain model)
  • Example 2: one phoenix “app” for endpoint + “plug” apps
    • The main phoenix app is very thin layer only for “plugging” other apps
    • This would be perfect if you can split behaviors with URL (e.g. /admin)

My advise would be to just start off with a single app structure. Elixir makes it very easy to refactor your app to an umbrella when, and most importantly, if that is ever needed.

You can separate your code in a single app structure as well (purely as an example):

  • lib/my_app contexts and schemas
  • lib/my_app_admin admin logic
  • lib/my_app_web frontend
  • lib/my_app_api api
  • lib/my_app_whatever whatever