Best practice for directory structure of a larger application?

cvh23
Thu, 08 Oct 2020 16:03:57 +0000
Questions / Help

Hey,

I am very new to the Elixir world, but doing software development for many years. The Elixir ecosystem looks very promising to me. Currently I am not sure how to structure a larger application in an optimal way. Let’s say I want to create a web shop application named “shop”, which is an API only (REST or GraphQL) application. I would structure it this way (disregarded Elixir):

shop

customers

payment

paypal

stripe
:

communication
:
.

With Elixir (Phoenix) it would be?

shop

lib

shop

customers

payment

paypal

stripe

communication
:

shop_web (all the web/api stuff)
:

But what about an Elixir structure like this:

shop

lib

customers

payment

communication

api (all the web/api stuff)
:

That would be more “natural” to me (for an API only application). Otherwise I would have repeated “shop” and all the code is split more or less in two main directories: “shop” and “shop_web”

Another question: Is it uncommon to have the application name in the module identifier/path? So it should not be “Shop.Payment.Paypal”, but just “Payment.Paypal”. Right?

How should the Ecto repo modules be named? “Payment.Paypal.Repo”? Or “Payment.Paypal.DB”? Should the Repo be seperated from related business logic?

Sorry for mixing the topics a little bit, but for me it’s somehow connected

25 posts - 7 participants