Sharing Ecto schemas between projects

Hi all,

I’m looking for some advice on how to structure an application I’m building. It should eventually contain an importer that runs daily and a Phoenix application to display the information. Seeing as both applications use the same data I decided to try out an umbrella application containing a “core library” that acts as a Data Access Layer whilst allowing the schema to be shared. The application hierarchy currently looks like the following…

  | apps
    | hcc_core
    | movie_importer
    | phoenix_app

This works well enough on my dev machine, however I’m having a hard time deploying using edeliver and am wondering whether that it a sign that there is a more optimal way to structure that application.

I’m pretty new to Elixir so any feedback or advice on sharing schemas between projects would be greatly appreciated.


1 Like

Looking at your structure, I guess You use mix new … --umbrella, then go to apps and build phoenix app.

But there is also another way of doing this

mix hull_cinema_club --umbrella

After, You build the movie_importer, You will get this structure

  | apps
    | movie_importer
    | hull_cinema_club
    | hull_cinema_club_web

WIth hull_cinema_club acting as core. I tend to prefer this, as it simplify struct a little bit, as there is no need to build phoenix_app and hcc_core by hand. And also, the web part is configured only for web. While the core is the db part.

Also configuring tests is automatic, while in your case, You will need to make it by hand.

It’s just a matter of taste, I used the same structure as yours before…


Thanks for the advice - I hadn’t thought to create the umbrella project using phoenix but I can definitely see how that makes things tidier. Also good to know that I’m not completely on the wrong track.

1 Like

Also, if you already have started the project as umbrella without the web piece, you can use mix generator inside apps to create the web layer using Phoenix. The generator will identify the umbrella project and will remove everything you don’t need in the web app.