Which architecture is best for Phoenix Framework?

I am new in phoenix world, I want to develop a web apps with Phoenix Framework but I am not sure, MVVM, MVC etc, which one best for that projects?

At work for the behavior, we use MVC.
But for the architecture we use CQRS/ES. It’s really really good.
I’m a huge fan. It mixes well with Contexts and how Phoenix works.

3 Likes

CQRS/ES is only for elixir world?

Nope. It’s an architecture available anywhere. For Elixir we use Commanded. But I did it in Ruby with Sequent.

1 Like

ok tnx so much:)

Command Query Responsibility Segregation and Event Sourcing are patterns used in the Domain-Driven Design methodology. Completely language agnostic

1 Like

I’ve been using Commanded in some side projects lately and I’ve enjoyed, but how have you negotiated the learning curve in a professional environment?

1 Like

It was the very first time I’ve used CQRS/ES and thus Commanded.
My CTO is a very nice guy and he pushed me directly on a big feature :smiley:
I’ve read the Build Conduit book from Ben Smith too.
To be honest it was not that hard. Except the command enrichment which and the queries part.

The projector part was also a tough cookie! Since it differs from a classic Phoenix system, we use projectors and projections to describe and persist data and not the repository layer.

Here’s my pros/cons:

pros:

  • the event system lets you react on a given event to trigger other events.
  • commanded do a lot for you, and you can extended it with macros.
  • head free because of the segregation

cons:

  • lot of files
  • sometimes the code is almost the same and you ended up with some kind of duplication
  • boilerplate code
  • tests (got hard times setting up the test suite)

As I said before, I’m a huge fan of it, despite all the files needed, it’s a real pleasure to work with.

Do you have a particular point that has stuck with you?

1 Like