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

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
minhajuddin
I have seen a lot of code which picks the first element from a list using Enum.at(0) instead of List.first. Is there a reason why people ...
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
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
joaquinalcerro
Hi there, I am working with Ecto-Postgresql and I need to call all of the records from a specific table but the table has 40,000 record...
New
chensan
I have a User schema with a :from_id field set to type :string: defmodule TweetBot.Repo.Migrations.CreateUsers do use Ecto.Migration ...
New
vonH
When I run the Plug and I recompile I wind up having to use Ctrl C to quit iex and start again. Witht the help of rlwrap I can use the cu...
New
Mooodi
Given a string, how can I get access to its character by index? Enum.at("my_string", 2) doesn't work. Or rather, not char, but a substr...
New
siddhant3030
Hi, I have to write a raw query for one of my project. But till now I have used ecto queries and don’t have much experience writing raw ...
New
joeerl
Hello again - after a longish gap I’ve decided I really must dig into Elixir and see what’s been happening here - so I have a few questio...
New

Other popular topics Top

lanycrost
Hi everyone! I need implement if…else if…else condition from my elixir code, and anymore of this control flow structures not work proper...
New
TunkShif
This post is an instruction guide to help you setup your Neovim for Elixir development from scratch. It includes general information on h...
273 38985 115
New
dotdotdotPaul
Okay, I'm having a heck of a time trying to figure out how to best handle the validation of belongs_to associations in Ecto. I'm sure I'...
New
axelson
This post is a wiki (feel free to hit the edit button near the bottom right of this post to add your own changes!) This post collects co...
239 45766 226
New
sergio_101
I am VERY much an elixir newbie. I have taken one elixir course and one phoenix course on Udemy. During that course, I saw the instructor...
New
Jim
As a follow up to my earlier question: I have the code compiling and running but not getting a successful login from the rest server. ...
New
vertexbuffer
Hello, can anybody help here..? I have a list of players and I what to delete an element, but every for loop the list is reverting to ori...
New
danschultzer
None of the current solutions worked well for me, so I went ahead and built a user management system from scratch. This project took far...
548 27727 240
New
fireproofsocks
Forgive me if this is obvious, but how does one delete a database record WITHOUT selecting it first? https://hexdocs.pm/ecto/Ecto.Repo.h...
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