What's your process on splitting application logic?

I have been trying ddd after reading

It’s probably possible to push design toward full compliance, but that would be a lot of work.

DTO to Domain Object is different, as Ecto uses changeset.

Bounded Context should own there own datastore, although it’s possible to multiple Repo, it’s not the usual way to build a Phoenix application.

I have tried a light ddd approach, but with Elixir specificity, where Data Taking (and all Phoenix contexts) is responsible for validating data, and then, in each Bounded Context, I define schemas.

It can be very different from the original data. It can use specific changeset, to update the underlying database, or be read-only.

One example…

defmodule MyApp.Scheduling.Medium do
  @primary_key false
  schema "events" do
    belongs_to :language, Language

    # id -> permalink!
    field :id, :string,
      source: :permalink,
      primary_key: true
   ...
    timestamps(type: :utc_datetime)
  end
...
end

This is a medium in a bounded context, but it is an event in the data taking context. It uses a different id than the original data.

It is a lot of duplication, I define specific schemas in each bounded contexts, but I know they are valid Domain Object, and can reshape and rename…

In each BC I have an event listener (a genserver), and use a domain event dispatcher (pubsub), to be reactive. I use LiveView in some part, and React in other. Bounded Contexts and UI are reacting to domain events. But this part is easy with Elixir :slight_smile: