New Phoenix 1.3 structure - Umbrella, Ecto

Hi,

I would like to ask something about the project structure and its best practice. I started with Elixir before Phoenix 1.3, work on some production projects wherein the majority we used Umbrella project setup, where one of Apps was named Core. This Core app had Ecto and other “connectors” for Kafka, Elasticsearch, etc. I run roughly 5 apps under Umbrella. I quite like this approach, though I miss some more topics/blog post/tutorials/courses/books on this topics. How to structure bigger projects Elixir or Erlang (I would assume that there should be a lot on this for Erlang, but sadly there isn’t). Especially in regards to later code updates, maintenance, …

So, I would keep this philosophy to use Core app for this connectivity issues/functionalities of my whole project setup

Now with Phoenix 1.3 and its directory structure change and this new concept of Context, I found it difficult to understand what would be best practice. Especially in regards to a new folder structure. Let say under phoenix project you have now 2 folders. lib/project_name and lib/project_name_web.

Now if I understand it correctly I should use Ecto and Context stuff under the folder lib/project_name. But how would you set up this, if even possible, under Umbrella project with my previous “approach” in mind? To totally remove DB layer out of the Phoenix app.

What happens then with Context? Is this ok? Do I lose all the good stuff?

I would really appreciate some guidance/tips/best practices here.

Best,
Tomaz

Phoenix 1.3 has specialized umbrella installation generators, where you can generate a phoenix app as part of an umbrella, which is just phoenix without business logic. The latter you can hold in your existing umbrella apps.

1 Like

If I move business logic, Ecto and all this to another app inside Umbrella project. Is then there still Context or I loose this while moving outside of phoenix app?

You’ll not really lose something because phoenix contexts are essentially just the idea of bundling functionality in modules, for the matter of communication named contexts.

Ok, so for the sake of old habits I don’t really loose anything if I move business logic / ecto with models, repos, schemas… into second umbrella app and use phoenix just for serving content towards the web?

@tomazbracic yeah you wouldn’t lose anything. And if you’re writing a new app phoenix will generate exactly that structure for you if you run mix phx.new --umbrella.

generate an umbrella application, with one application for your domain, and a second application for the web interface.