Boundary - enforcing boundaries in Elixir projects

@balduncle Yup, umbrella allows to have multiple OTP apps in one meta-project with less ceremony (although opinions on that vary :)) than managing multiple projects altogether.

And indeed umbrella’s main concern isn’t validating cross-module deps i.e. what boundaries does - as stated in the official guide umbrella has drawbacks in that department.

What umbrella does that could be perceived as similar to boundaries is that it allows to split app code into higher level buckets compared to modules i.e. OTP apps and that it draws dependencies between those apps via deps with in_umbrella BUT it’s a very unreliable tool for guarding these dependencies because if app A always declares dependency on app B and app B doesn’t declare dependency on app A, it still can call code of app A without warnings because these apps are always present together in the build.

Therefore I rather see umbrella as tool for exactly what you wrote i.e. creating heterogenic releases made of different sets of OTP apps, than a code organization tool.


It would be a little bit hacky and I do not know if it would be good place for it, but you could “overuse” @moduledoc attribute with attributes (is it proper nomenclature?):

defmodule MyBoundary do
  @moduledoc exports: [
    # …


I want to thank you all for providing the encouraging feedback and some great food for thought. Owing to your comments, I’m even more convinced that we can build a solid boundary enforcement tool for Elixir.

As a result of your comments, and the issues reported on the repo, I now realize that some of my original ideas were not on the right track. That’s actually a good thing! While I was a bit reluctant about sharing my work at such an early stage, I’m now happy that your review helped me discover some foundational problems so early on in the process.

So at this point, I’m increasingly leaning towards the following changes:

  • allowing partial coverage (not all modules have to be a part of some boundary)
  • switching to a decentralized solution
  • prioritizing nested boundaries (boundaries within boundaries)

I plan on writing a detailed proposal, but I probably won’t make it this week, so I just wanted to let you know that I’m intensively thinking about this.


This looks awesome!

To the tune of how boundaries can be awesome, we had a JavaScript project which was 1 codebase split across background and foreground pages (chrome extension). Implementing a boundary type system ensured that we never put background-only concepts in the foreground (where they would break). I caught several errors that I added in once this boundary checker was implemented.

Having a similar type of concept for organizing Elixir code would be really useful. I’m convinced that “people policies” are not enough, only tools can guarantee it. The compiler seems like the right place for it.


I finally found some time to make the proposal for the changes I’d like to do in boundaries. You can find it here. Looking forward to hear your feedback!


FYI, I started working on the proposed changes. See this comment for details.


The first draft of all proposed changes is now implemented in this PR. Note that some parts (most notably ignoring checks) are implemented in a somewhat different way. The relevant links are included in the PR description. I’ll leave the PR sit for awhile in hope of getting some feedback.


The PR has now been merged, and the repo has been renamed to boundary.