I’ve been exploring Phoenix.Context
recently and noticed that many projects seem to structure it differently.
Let’s say we have a context called Catalog
, which includes two sub-schemas: Product
and Category
.
Following the typical approach:
catalog.ex
should contain the CRUD operations and business logic for bothProduct
andCategory
.catalog/product.ex
should contain the schema definition and changeset logic forProduct
.
However, when the CRUD logic becomes extensive, catalog.ex
grows too long, and you might need to split it up. At that point, it feels like the community has all sorts of ways to handle it—there’s no real standard…
My current idea is to structure it like this:
- catalog/products.ex
- catalog/products/product.ex
- catalog/categories.ex
- catalog/categories/category.ex
- catalog.ex
But the module names feel quite long… it’s like having contexts within contexts.
How do you all usually handle this?