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

vrod
I am using the Starship cross-shell prompt – it seems pretty nice, but I get some errors: [WARN] - (starship::utils): Executing command ...
New
senggen
Erlang/OTP 25 [erts-13.2.2] [source] [64-bit] [smp:8:8] [ds:8:8:10] [async-threads:1] 15:22:35.803 [error] gen_event {lager_file_backend...
New
SoCreat
i’m a new one to elixir which editor can i use vs code? or atom? Thanks! :smiley:
New
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
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
Werner
Hi, I’m using Ubuntu 18.04 and after updating to OTP-24.0 yesterday i have this warning when I run “mix local.hex”: 14:57:30.512 [warn] ...
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
lk-geimfari
What is most correct way to open, read and parse JSON file with poison? For example if we have example.json file in root of some projec...
New
alice
Hey, Just curious what are the main benefits of Elixir compared to Clojure? When is Elixir more useful than Clojure and vice versa? Th...
New
WestKeys
Currently suffering from paralysis by [HTTP client] analysis. This is rather unusual in Elixirland as there tends to be consensus on the ...
New

Other popular topics Top

JakeBecker
TL;DR: I’ve just released an implementation of Microsoft’s IDE-independent Language Server Protocol for Elixir. It adds language support ...
1140 51847 244
New
Brian
What is the proper way to load a module from a file in to IEX? In the python world, doing something like this pretty standard: from ....
New
malloryerik
Hi, this is for people who, like me, have had some friction using .html.heex templates in VSCode. The solution seems to be, in a hyphena...
New
dokuzbir
Hello, I am trying to convert my lists to string without losing brackets.For start i have 3 map. They look like these buyer = %{ id: ...
New
alice
Hey, Just curious what are the main benefits of Elixir compared to Clojure? When is Elixir more useful than Clojure and vice versa? Th...
New
msaraiva
Surface is an experimental library built on top of Phoenix LiveView and its new LiveComponent API that aims to provide a more declarative...
564 42633 214
New
johnnyicon
Hi all, I've just started learning Elixir and Phoenix Framework, so please pardon my n00bness at this stage. I'm trying to use Postg...
New
electic
Hi, I am new to Elixir. I am trying to use the DateTime component to insert a date into MySQL however the there seems to be no way to fo...
New
skosch
To my knowledge, put_in, Map.update etc. all have the one limitation of not automatically creating intermediate keys when needed (for exa...
New
AstonJ
by Lance Halvorsen Elixir and Phoenix are generating tremendous excitement as an unbeatable platform for building modern web application...
460 27162 124
New

We're in Beta

About us Mission Statement