Sanjibukai

Sanjibukai

Elixir with Ecto (and Phoenix without Ecto)?

Hello everybody,

Tl;Dr: How to decouple the “web interface” from the “business logic” when a database is involved.

I watched the following talk from 2016 given by Lance Halvorsen https://www.youtube.com/watch?v=lDKCSheBc-8 about “Phoenix is not your application”.

I don’t know if this is something rather accepted in Elixir/Phoenix communities or if it’s only the thought of the speaker.. But I couldn’t agree more with this statement.
Particularly coming from Rails where Rails is considered your application (to quote DHH).. Which I never really agree with that.

I even heard about not using at all Ecto within Phoenix apps (applying --no-ecto) and letting a regular Elixir app taking care of the business logic. An example I heard is from the course Elixir for Programmers by Dave Thomas. But it seems (I didn’t took the course yet) that in this case the business logic doesn’t use a database.
And I somehow understand how the Phoenix web app will communicate with the Elixir “domain” app using OTP.

But, I wonder if this approach is still applicable to application that have a business logic that actually uses a database.
And so, if Ecto is intended to be used solely with Elixir? I mean without Phoenix..
Or put it in another way I want to know if Phoenix is doing a lot under the hood in using Ecto.

But I also took a look at the following talk from 2017 given by Chris McCord https://www.youtube.com/watch?v=tMO28ar0lW8 where he explains how Phoenix from 1.3 is distinguishing the web part (the web interface) from the logic/domain part.

So I wanted to ask you, Elixir/Phoenix folks, what’s the best approach you’ve experienced?

I’m asking this question in the context of an application that could become relatively large and complex regarding the logic/domain..

I’ve already had a bad experience with Rails working with large applications (very probably also because of a bad design too) and I really love the approach of having applications completely decoupled regarding the web interface and the business logic.

I hope this makes sense and I’m sorry if it’s rather confusing and also for the bad English..

Most Liked

outlog

outlog

No, we just tend to mix them all up - call the DB directly in controllers/channels etc. - have business logic in controllers/channels etc. etc.

It makes good sense to keep them seperate - say in MyApp(ecto and business logic) and MyAppWeb(phoenix that calls MyApp for data and data processing)

this is a great talk on DDD - but also look into various materials on using “Contexts” search this forum etc.

ps: in a large app you might even see multiple Phoenix apps..

ityonemo

ityonemo

I have deployed elixir with no Phoenix or ecto, elixir with ecto and plug and no Phoenix. I’m currently deploying elixir with a phoenix admin panel, and a json API in plug (no ecto)… It all depends on what you need.

Where Next?

Popular in Questions Top

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
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
qwerescape
Is there a way to get the call stack or stack trace at any point in the code? Not from exceptions, but an expression that returns how the...
New
JeremM34
Hello, how can I check the Phoenix version ? Thanks !
New
shahryarjb
Hello, I get Persian date from my client and convert it to normal calendar like this: def jalali_string_to_miladi_english_number(persi...
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
JorisKok
I have a server on AWS, and was running a load test using artillery. When looking at the Phoenix dashboard I see the Ports going to 100% ...
New
hariharasudhan94
lets say i have a sample like a = 20; b = 10; if (a > b) do {:ok, "a"} end if (a < b) do {:ok, b} end if (a == b) do {:ok, "equa...
New
RisingFromAshes
I’ve read in another post that it may be possible with a router helper - but I couldn’t find an appropriate one, and tbh, I’m still just ...
New
jononomo
For some reason my phoenix channels are working for me in my local dev environment, but as soon as I deploy via Docker, I get a 403 error...
New

Other popular topics Top

Darmani72
If I have a post route which an argument: post /my_post_route/:my_param1, MyController.my_post_handler How would get the post params ...
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
AstonJ
Posting this to see if we can make things easier for people to get into Neovim. If you use Neovim and have a favourite distro please let ...
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
chrismccord
This release brings a number of exciting features, including integration with the new Phoenix LiveDashboard and Phoenix LiveView. There h...
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
nobody
Hi! In PHP: $_SERVER[‘SERVER_ADDR’] - in Elixir? Searched the docs for ip address and the web, no good results. Thanks!
New
rms.mrcs
Hi, I need to transform a list of numbers into a map where the keys are the indexes and the values are the original values of the list. ...
New
shijith.k
I am trying to start a new phoenix project with elixir 1.9, but mix phx.new does not work. It says that ** (Mix) The task "phx.new" could...
New
dogweather
I wrote this comment on r/haskell, and it’s not popular there. :wink: But I think I’m on to something… Haskell reminds me of Java, and e...
New

We're in Beta

About us Mission Statement