Good directory to put "stores" into?

If you were using “stores” to abstract over Models and Repo where would you put store modules?

1 Like

The direction Phoenix is taking is to go away from directories with given names where you put everything. In some cases it makes sense, like controllers and views, as they are mostly callbacks in a certain shape invoked by the framework (even though the imposed shape in Phoenix is very small: such as a render/2 function in views).

When you take Phoenix out of the equation, which is the presentation part, you end-up with the multiple contexts that exist in your application. Your account management, your payment processor, etc. That’s just Elixir code. Modules with functions that act on your domain.

A store is likely an implementation detail and should belong inside a context. Why would you put all of them together? This also avoids the awkward place that code generators often put us, which is to make us think that every resource in our application need to have a store (or a schema, etc), while you should rather create stores when you think one will be useful.


Thank you for the detailed answer, makes total sense was just wondering what would be considered “idiomatic” in Phoenix context. Things are all over the place with other frameworks from very rigid to say Hapi.js where people often store even controllers and routes split into plugins by context.

1 Like