Organising an existing app into Bounded contexts

I’m just looking at upgrading an app to Phoenix 1.3. It’s a multi-tenant app (we’re using Apartmentex) which contains a Phoenix app and a CLI tool for managing the tenants (e.g. add/delete tenant). The Tenant ecto schema is used by both the Phoenix app and the CLI tool, and they both make use of
APIs for OneSignal and Auth0.

Given the introduction of Bounded contexts in 1.3 I’m considering how best to organise the modules. On the one hand the operations that the Phoenix app and CLI tool perform are entirely separate, which leads me in the direction of separate Bounded contexts, but on the other, the Tenant ecto schema is shared between the two as are the OneSignal and Auth0 APIs (although again, the operations are separate).

My feeling is that separate Bounded contexts makes sense here, certainly it’s the most effective way to communicate which code is related. I’m curious what people’s thoughts are though, what factors do you consider when deciding whether or not to break out a new Bounded context?

1 Like