JoeZMar

JoeZMar

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.

Showing Posts 1 to 8

maz

maz

Take a look at this thread:

I suggest just start with that. It’s easy to get into ‘analysis paralysis’

cohawk

cohawk

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

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.

JoeZMar

JoeZMar OP

This was my original thought was that each app would hold its own schema (a great example is my users and admins have two separate schemas, but are used for the same table). If I created a Db app, what responsibilities should it have?

Right now here is how I am thinking about structuring my umbrella project:

user_interface ----                 |---- Auth
                   |- app_name -----|
admin_interface ---                 |--- (Additional Micro-services that create the app)
                                    |---- Elixir App hooked up with Ecto and a DB

Does the database application only contain functions within its Context to help the other microservice applications in the umbrella create records?

For example within the Database application a function in the context might look something like:

def create_record(table, schema, attrs) do
   ...
end

and each application has it’s own schemas and makes the request to the database app this way.

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:

JoeZMar

JoeZMar OP

Okay thanks for the help. This answers my question because I hadn’t thought of the possible helper functions that a db app could hold.

zubairshokh

zubairshokh

Did you go with the single Repo or multiple Repo(each app with its own repo) structure.

@mbuhot what is better in this situation. a single repo or the multiple repo? if the structure is decoupled already.

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.

— All posts loaded —

Where Next? Top

Trending in Questions Top

RSP87
I’m working on a project that simulates the bumbl example in the programming phoenix book. It acts almost like an email client. We have a...
New
RemyXRenard
I’m seeing that a list inside a Kino.DataTable will be interpreted as a charlist, even if the Kino.configure() is set to charlists: :as_l...
New
velrest
So my question is quite simple and i have found no conclusive answer on forum, google or AI. Should we use :erlang.float for Integer to ...
New
nseaSeb
Hello, I know there is an approach for handling lists that allows for optimized traversal, but I can’t recall the specific method (somet...
New
samoloth
Hi, I’ve just set up an application with ash_authentication. There is only magic link strategy for now, so there is no confirmation add o...
New
FlyingNoodle
If a change or preparation module uses Ash.Changeset.get_argument/2 or Ash.Query.get_argument/2 (or any of the other get_argument functio...
New
ryanwinchester
apply_graft/2 doesn’t rewrite an add_many sub-workflow’s deps on an add step. Grafted jobs cancel with “upstream job was deleted” Version...
New

Other Trending Topics Top

mudasobwa
I am happy to introduce the very α version of the new programming language compiled to BEAM. Welcome Cure. It has literally three kille...
New
marciok
Hi there! We created Gust: A task orchestrator inspired by Airflow. For those who have never heard about Aiflow, it’s a Python-based wor...
New
jimsynz
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New
Dmk
Xamal is a deployment tool for Elixir apps that deploys native releases to bare metal servers over SSH. It’s a port of GitHub - basecamp/...
New
Damirados
Hello everyone. After busy few months I am happy to announce v0.1.0 of Emerge & Solve. They are GUI (Emerge) and State management (S...
New
netoum
Corex is an accessible, unstyled UI component library for Phoenix that integrates Zag.js state machines using Vanilla JavaScript and Live...
New

We're in Beta

About us Mission Statement

Options

Thread Display Mode




Thread Preview

Skip Thread Previews