JoeZMar

JoeZMar

Separating the DB in an Umbrella project

I am making my first umbrella project right now and I want to separate the database into it’s own application. I am trying to understand how to appropriately break up an umbrella project.

Here is what I am thinking so far:

My app has two web interfaces: user_web & admin_web

In addition I have an app to handle the backend logic: app

Right now my two web interfaces talk to the one backend logic app that I plan on connecting the rest of the micro-service apps to.

Here is where things get dicey for me. I’ve seen a few videos where the app was broken down even further into several micro-services. I haven’t found a decent/modern example that shows how small these micro-services should be. If I was adding authentication to my app I could create a micro-service for Authorizing users and have that as a separate app. I feel like I kind of understand this concept (or can at least figure it out) until I started to introduce the concept of separating the database.

From what I’ve read it seems like creating a separate application to serve the database logic is the way to go and have that app connected to the only database in the umbrella project. Does that mean when I introduce the ability to create users within my umbrella project the schema is stored within the database logic app or the app responsible for implementing the users?

I think if I understood the layer that manipulates the database application and how it i should implement the db api I can figure out how each piece of my app should fall together.

My app is eventually going to be very large including several services for different agencies and a few different native mobile applications so I really like the idea of having well thought out applications that are small and functional so they can be easily plugged into our future apps we create.

Most Liked

mbuhot

mbuhot

One of the great features of Ecto is that the schema structs don’t need to map directly to tables. This allows each umbrella app to manage its own schemas, and the shared DB app just defines the repo module, migrations and configuration.

cohawk

cohawk

The CaptainFact API might be a good example project for what you are trying to accomplish.

mbuhot

mbuhot

Not sure if create_record is a great example, since there’s usually Changeset validations associated with record creation.

But other generic helpers like adding Pagination clauses to a Query, or multi-tenancy concerns might belong in a DB application.

I’d avoid wrapping the Repo API, since a Repo is already a fine DB abstraction layer. :slight_smile:

mbuhot

mbuhot

I’d start with one Repo then split it into multiple when you want to isolate access to the tables using postgresql Schemas (aka namespaces) and separate roles/ permissions for each Repo.

Where Next?

Popular in Questions Top

JDanielMartinez
Hi! May someone helps me, please! I have two apps into an umbrella project: the first one is Database, which manages queries, and the se...
New
vonH
In asking this question I am more interested about the expressiveness of the language itself and less concerned about the availability of...
New
lessless
I believe there are people here who are dealing with CSV files import on the daily basis, and since Excel is a really popular tool there ...
New
jerry
Good day to you all. I have been struggling to get a query involving like and ilike to work. Can anyone assist me on this, please? pro...
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
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
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
stefanluptak
Hello everybody, usually, I use a 29" ultra-wide monitor for VSCode which can easily accomodate explorer (files panel) + file with code ...
New
chrisalley
ExUnit now has describe blocks which is a welcome addition coming from RSpec. In the docs, it states that nested hierarchies of describe ...
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

Other popular topics Top

sergio
In Ruby, I can go: User.find_by(email: "foobar@email.com").update(email: "hello@email.com") How can I do something similar in Elixir? ...
New
stefanchrobot
What’s the safe way to decode a JSON string into a struct? I want to avoid calling String.to_atom. Jason.decode can give me a map with st...
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
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
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
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
9mm
I am constructing a JSON object (map) and I need to conditionally set a field. I’m trying to write proper elixir-way code… and I’m at a l...
New
lucidguppy
I have a super simple question about elixir - how would I take a file like this foo bar baz and output a new file that enumerates th...
New
aesmail
Hello guys, I have finally made it. I created an admin interface for a framework. It’s been on my todo list for years and with the curre...
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

We're in Beta

About us Mission Statement