skip to Main Content

so I’ve got a big phoenix project that only does json. Brunch et al not even installed. Now we’re creating public-facing pages that needs to be SEO friendly, so we’re going to use the standard browser pipeline and render html templates etc. This public facing app will likely be deployed to its own instances and scaled independently. I want to share my core schema/model code and some utils. How should I set this up? Umbrella? separate projects? (will still be in same repo though)

I’ve received advice to start with an umbrella app, but I have two questions with that:

1) If I have them configured for different ports, will running mix phx.server from the root run them both ok?

2) should I move the shared code out to its own app (so I have 3, shared app, json app, html app) and will I get the auto reloading (without having to kill/restart the server) when I change code in the shared app?

2

Answers


  1. You can have as many web apps (Phoenix) as you like in a single umbrella project. The only nuance is setting the port for each differently. However, if the web apps are APIs that are going to call each other, be sure your API facade code is within a shared app as you do not want to include web1 as a dependency of web2 due to the possibility of circular references as well as additional concerns when building a release.

    Additionally any shared code should go into one or more additional applications within the umbrella.

    Login or Signup to reply.
  2. I’ve been working on a similar type of app. I have 4 apps in my main umbrella

    • DB Elixi app which abstracts all db related stuff as I connect to Cassandra & Neo4j
    • Web *Phoenix App
    • Api *Phoenix App
    • Tasks Elixir app with some gen servers to do background tasks

    From the root of the app I run mix phx.server which starts all phoenix applications and starts the other elixir apps too. If you want to test a single part of the application just cd into the apps/{app_name} folder and run commands from that scope.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search