bruno_louvem

bruno_louvem

Approach to microservice dependecies in umbrella project

Greetings, everyone! In an attempt to get to know about the best practices
when dealing with umbrella application projects, I’d like to share an
architecture-related dilemma that my team and I have recently faced.

Our goal was to structure our umbrella apps in a microservices-like fashion,
with a single underlying database storage. At first, each app would have their
own schema, model and domain definitions, but this eventually led to circular
dependency issues when inter-app references began to pop up.

To illustrate, we have an “Auth” app, with entities associated with
authentication, and a “Profile” app, to store additional personal info (phone
number, profile picture, etc.). We could not figure out how to build a
“belongs_to” <-> “has_one” relationship between entities from these two apps
since each one would have to depend on the other to be able to reference the
schema module contained in the other app.

After a bit of research, we stumbled upon a proposition for an architecture
containing an additional umbrella app (say “Datasets”), dedicated to interfacing with the database.
This way, every other app would have it as a dependency, and all the schema
definitions would be stored within this app, organized according to namespaces
such as Datasets.Auth.User, Datasets.Profile.Account

Given that this system wouldn’t need to rely on heavy decoupling of its apps,
are there any anti-patterns in this approach that could cause trouble in the
long run?

Most Liked

arkgil

arkgil

IMO if all your services share the data store then they are one, single service. If you need an extra application for handling database schemas, which all other apps depend on, to me that’s an indication that those apps shouldn’t be thought of as distinct services. You could as well use a non-umbrella project with all schemas namespaced under Datasets. module.

subetei

subetei

Couldn’t find a lot of good examples of this myself when researching this. Sharing what’s worked for me the last few months… it’s similar to your proposal and hasn’t caused an issue yet.

Umbrella - All deployable services

  • Web
  • Api
  • Process server

Data App - own individual repo/app
Search App - own individual repo/app

Didn’t put the others in an umbrella, each lib outside of umbrella is individual atm. And yep it’s easy in Phoenix for example to replace in the application tree your ecto source so my access looks like DataService.QueryPost.get_something… The search works the same and any of my umbrella apps can opt in to either service.
I could see the use of putting the extra shared libs in an umbrella since its easier to add new projects without temptation to cram things into data. Interested what more experienced elixir folk say but can say after many features and about 10 big deployments this still holds up

AstonJ

AstonJ

I’m extremely interested in the Replaceable Component Architecture and I highly recommend PragDave’s new online course:

It has sparked some really interesting discussions on the forum and I think every Elixir developer would find that course invaluable - even if just to see how other experienced developers are using Elixir. I’m personally really excited by what he’s a proponent of and can’t wait for his next course :003:

With regards to your question, I actually emailed Dave asking if he would go into some of that in his next course… hopefully he will (he doesn’t use Ecto in the current course and I’d personally like to see how persisted and more closely related data is dealt with in his approach).

Where Next?

Popular in Questions Top

bsollish-terakeet
Credo is smart enough to check for (something like) this: assert length(the_list) == 0 with this response: Checking if an enum is empt...
New
gshaw
What is the idiomatic way of matching for not nil in Elixir? E.g., First way: defp halt_if_not_signed_in(conn, signed_in_account) when...
New
pgiesin
This should be a simple problem but I just can’t seem to figure it out. I have a standalone Elixir app that won’t find the database. Dep...
New
jononomo
I am trying to figure out how Mix knows whether the environment is test, dev, or prod -- where is this set? Thanks.
New
fireproofsocks
I’m working on defining a simple Ecto schema for a table (in PostGres), but I don’t see where I can define a column as NOT NULL. Conside...
New
sacepums
Hey guys. I'm new to elixir and im really stocked about it. But I ran into a bit of problem - I need to convert a date sting, for examp...
New
hariharasudhan94
I would like to know what is the best IDE for elixir development?
New
mathew4509
I have a list say x = ["23gh", "56kh", "97mh"] I would like to pass each element to Val in each iteration. Say, in iteration 1 -------...
New
fayddelight
I tried installing elixir 1.11.2 erlang 23.3.4 via asdf in my zsh shell. Enabled the versions locally and globally. When I list them ...
New
gonzofish
I’m currently trying to understand how to join three tables using Ecto. All the examples I’ve seen use 2, so maybe I’m just missing somet...
New

Other popular topics Top

peerreynders
Manning 2016 Halloween weekend sale via Deal of the Day Friday, October 28 - Half off all MEAPs - code WM102816LT Saturday, October 29 ...
326 29600 154
New
srinivasu
How to handle excepions in elixir? Suppose i have A, B, C ,D, E modules. and each module has get() function. A.get() method will call th...
New
pmjoe
I have a relationship of love and hate with Elixir. Lots of things are just absolutely right, but there are some things that are kind of ...
New
aalberti333
As the title describes, I’m trying to run Enum.map() over a list of key/value pairs, where the value is a map. My data looks like this: ...
New
ycv005
I have followed this StackOverflow post to install the specific version of Erlang. And When I am running mix ecto.setup then getting fol...
New
chrismccord
This release brings a number of exciting features, including integration with the new Phoenix LiveDashboard and Phoenix LiveView. There h...
New
lastday4you
I wanted to check elixir version in phoenix because i found that my elixir is 1.5 but when i use Enum.chunk_by it said the function is un...
New
myronmarston
The Elixir Typespec docs show the following syntax for keyword lists in typespecs: # ... | [key: type] # keyword lis...
New
ovidiubadita
Hey all, I discovered Elixir and I love it. I always wanted to learn a functional programming and I intended to go for Haskell, but afte...
New
vrod
I am using the Starship cross-shell prompt – it seems pretty nice, but I get some errors: [WARN] - (starship::utils): Executing command ...
New

We're in Beta

About us Mission Statement