AstonJ

AstonJ

Vertical slicing architecture in Phoenix - anyone utilising it? Pros/cons?

Anyone doing vertical slicing in a Phoenix app? If I am understanding the term correctly this essentially means you can organise your app’s files by individual components - so a bit like Phoenix Contexts but going a step further by directory. For instance you could have a Registrations component and all the relevant files would be in the registrations directory, or you could have a Profiles component and all its files in there, etc.

I’m not sure why I am thinking it but seem to recall there may have been a downside to vertical slicing in Pheonix but the conversations I am thinking of might be out of date. Hence curious, are you doing vertical slicing? How’s it going? Any pros or cons you think are worth sharing or advice for anyone thinking about using the architecture in their next app?


Please note the four posts below have been moved here from another thread.

Most Liked

sodapopcan

sodapopcan

I often organize the web directory by feature as opposed to by type, but I strong prefer to draw a hard line between the domain and web layers. Contexts are not always 1-to-1 with web sections.

FlyingNoodle

FlyingNoodle

In elixir apps the module names define structure, not the path, so you can already do something like this in phoenix anyway?

foo/
foo_web/
├─ feature_1/
│  ├─ components/
│  ├─ liveviews/

maybe I’m completely misunderstanding your question.

sodapopcan

sodapopcan

I’m finding it very hard to write a succinct answer to this, lol, as it can get really into the weeds with certain designs. I do mean Phoenix, though, yes.

I believe here we’re talking about also including the domain layer, so the structure would really be:

foo/
├─ feature_1/
│  ├─ components/
│  ├─ liveviews/
│  ├─ context.ex

BUT, maybe I’m misunderstanding but I don’t think so?

Otherwise, @AstonJ a quick example is that I have a client app which is for managing a catalogue of artwork for a visual artist. The app has several LiveViews but there are two that both deal with listing artwork, one for the artist to manage her catalogue (this one is super complex with different views and tons of info) and one client facing that simply lists out all the artwork and allows them to requests licenses for them.

This is where I don’t want to get too much into the weeds because I could totally have two contexts here (with different schemas), one that lists artworks in the context of the artist herself looking at them, and one for clients to browser. I made the intentional decision to forgo this and simply have a flag on an artwork which says whether it can be shown for licensing or not. SOOOO, the Catalog context gets used in both the artwork management feature, and the “license requesting” feature. It’s a bit simpler but does mean I have to deal with ensuring some fields can’t be shown to my client’s clients.

Otherwise, I like to have that firm line between domain and web because I want the domain layer to be able to operate entirely on its own. The web layer is simply a client, IEx is another. But maybe I just need to see a really good example of vertical.

Where Next?

Popular in Discussions Top

sashaafm
I’m trying to evaluate the best combo/stack for a BEAM Web app. Right now I’m exploring Yaws a bit, after having dealt with Phoenix for a...
New
pillaiindu
In django there is a cache framework backed by memcached. Rails also puts a lot of emphasis on caching, and even the idea of russian-doll...
New
mmmrrr
Just saw that dhh announced https://hotwire.dev/ Is it just me or is this essentially live view? :smiley: Although I like the “iFrame-e...
New
Ankhers
Just a little information upfront. Generally speaking, if I feel like I need to either break a pipe chain or use an anonymous function in...
New
lorenzo
Hey everone! I created a prototype for my app using Nodejs for the api. But the framework I chose wasnt great (in general theresnt any g...
New
ejpcmac
I have discovered Nix last month and I am currently on my way to migrating to it—both on macOS at home and the full NixOS distrubution at...
New
New
boundedvariable
I am going through the kafka architecture. All the features what the kafka is providing are already in Erlang. I would like hear your opi...
New
rms.mrcs
A couple of days ago I was discussing with a friend about different approaches to write microservices. He said that if he was going to w...
New
New

Other popular topics Top

aadeshere1
I have a another noob question about loop. Since elixir is immutable, while loop is not directly possible. total = 10 while total != 0 ...
New
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
chrismccord
As promised, the first release candidate of Phoenix 1.3.0 is out! This release focuses on code generators with improved project structure...
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
josevalim
Hi everyone, One of the features added to Elixir early on to help integration with Erlang code was the idea of overridable function defi...
New
Lily
In templates/appointment/index.html.eex: <%= for appointment <- @appointments do %> <tr> <td><%= appoi...
New
freewebwithme
Using vs code and installed ElixirLS: support and debugger. And I got an error popped up on start up says Failed to run ‘elixir’ comma...
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
KronicDeth
Elixir plugin for JetBrain’s IntelliJ Platform (including Rubymine) This is a plugin that adds support for Elixir to JetBrains IntelliJ...
289 36352 110
New

Latest on Elixir Forum

Elixir Forum

We're in Beta

About us Mission Statement