<turbo-stream action="append" target="posts_list"><template>    <div class="postbit" id="37295" data-post-id="37295">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="AlexMcConnell" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/AlexMcConnell/120/3875_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  AlexMcConnell
                    <span class="op-star" title="Thread Starter">
                      <img alt="OP" class="op-star-icon" src="/assets/thread-icons/thread-icon-thread-starter-df91e872.png" />
                    </span>
                  </h3>
		          </div>
						
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<aside class="quote no-group" data-username="McElaney" data-post="103" data-topic="5929">
<div class="title">
<div class="quote-controls"></div>
<img alt="" width="24" height="24" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/mcelaney/48/1565_2.png" class="avatar"> McElaney:</div>
<blockquote>
<p>not because of any sort of magic the generators provided</p>
</blockquote>
</aside>
<p>I wasn’t talking about the generators. Rails is magic.</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="37295" data-batch-url="/posts/batch_likers">
                        0
                      </span>
                      <!-- <span class="thread-count js-solved-indicator" title="Marked as solution"></span> -->
	                </div>
	                <div class="go-to-post">
	                  <a title="Go to post" alt="Go to post" href="https://forum.elixirforum.com/t/contexts-a-barrier-too-high-for-newbies/5929/104">Post #103</a>
	                </div>
	            </div>
              <div id="likers-container-37295" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="37295"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-standard-post cat-standard-post" title="Post #103"></div>
  </section>
</div>
    <div class="postbit" id="37470" data-post-id="37470">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="hubertlepicki" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/hubertlepicki/120/6822_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  hubertlepicki
                  </h3>
		          </div>
						
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>To be fair, I don’t have much love for Phoenix approach to “contexts”. Personally I do not see this as something I will use, and I actually agree that I will not recommend this to be used by newbies either.</p>
<p>I do think that Elixir/Erlang/Phoenix already comes with better alternative in form of umbrella application / Elixir/Erlang applications. And, truth to be told, Phoenix 1.3 does improve support for umbrella applications in form of new generators <code>phoenix.new.web</code> or <code>phoenix.new.ecto</code>.</p>
<p>I currently use approach of having umbrella app containing of several applications: “base” or “core” where say Ecto is used, “web” or “user_interface” where user-facing UI sits, “admin_interface” or “backend” for UI to perform administrative tasks etc. It is already easy and convenient to create such applications, and they do have additional advantage over contexts that they can be easier built, deployed, restarted as units.</p>
<p>Contexts seem like a way to improve the code structure of application where you put everything into “web” application. Which is not something I want to do in first place <img src="https://forum.elixirforum.com/images/emoji/apple/slight_smile.png?v=15" title=":slight_smile:" class="emoji" alt=":slight_smile:" loading="lazy" width="20" height="20"></p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="37470" data-batch-url="/posts/batch_likers">
                        2
                      </span>
                      <!-- <span class="thread-count js-solved-indicator" title="Marked as solution"></span> -->
	                </div>
	                <div class="go-to-post">
	                  <a title="Go to post" alt="Go to post" href="https://forum.elixirforum.com/t/contexts-a-barrier-too-high-for-newbies/5929/107">Post #106</a>
	                </div>
	            </div>
              <div id="likers-container-37470" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="37470"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-standard-post cat-standard-post" title="Post #106"></div>
  </section>
</div>
    <div class="postbit" id="37471" data-post-id="37471">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="AstonJ" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/AstonJ/120/15_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  AstonJ
                  </h3>
		          </div>
						
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p><em>//</em><br>
<em>Some posts regarding the OP’s intentions have been removed - generally we tend to give people the benefit of the doubt - but if you feel someone is a ‘bad actor’, please flag their post for a moderator to take a look (rather than tackle them yourselves) - this helps the thread from getting derailed. Thanks <img src="https://forum.elixirforum.com/uploads/default/original/2X/a/a1c41c89c299189a3f85edfeb4973563d8bac781.gif?v=15" title=":023:" class="emoji emoji-custom" alt=":023:" loading="lazy" width="20" height="20"></em><br>
<em>//</em></p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="37471" data-batch-url="/posts/batch_likers">
                        4
                      </span>
                      <!-- <span class="thread-count js-solved-indicator" title="Marked as solution"></span> -->
	                </div>
	                <div class="go-to-post">
	                  <a title="Go to post" alt="Go to post" href="https://forum.elixirforum.com/t/contexts-a-barrier-too-high-for-newbies/5929/108">Post #107</a>
	                </div>
	            </div>
              <div id="likers-container-37471" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="37471"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-standard-post cat-standard-post" title="Post #107"></div>
  </section>
</div>
    <div class="postbit" id="37500" data-post-id="37500">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="wmnnd" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/wmnnd/120/4985_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  wmnnd
                  </h3>
		          </div>
						
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<aside class="quote no-group" data-username="hubertlepicki" data-post="107" data-topic="5929">
<div class="title">
<div class="quote-controls"></div>
<img alt="" width="24" height="24" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/hubertlepicki/48/6822_2.png" class="avatar"> hubertlepicki:</div>
<blockquote>
<p>I do think that Elixir/Erlang/Phoenix already comes with better alternative in form of umbrella application / Elixir/Erlang applications. And, truth to be told, Phoenix 1.3 does improve support for umbrella applications in form of new generators phoenix.new.web or phoenix.new.ecto.</p>
</blockquote>
</aside>
<p>I also quite like to use umbrella applications instead.<br>
But then again, for newbies just starting out with Elixir, <em>that</em> might actually be a little bit too much.</p>
<p><a class="mention" href="/u/josevalim" rel="nofollow">@josevalim</a>, <a class="mention" href="/u/chrismccord" rel="nofollow">@chrismccord</a>: Why did you decide to go with Contexts  rather than umbrella applications by default? Was it the concern that going all-OTP right away might overwhelm new users?</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="37500" data-batch-url="/posts/batch_likers">
                        0
                      </span>
                      <!-- <span class="thread-count js-solved-indicator" title="Marked as solution"></span> -->
	                </div>
	                <div class="go-to-post">
	                  <a title="Go to post" alt="Go to post" href="https://forum.elixirforum.com/t/contexts-a-barrier-too-high-for-newbies/5929/109">Post #108</a>
	                </div>
	            </div>
              <div id="likers-container-37500" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="37500"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-standard-post cat-standard-post" title="Post #108"></div>
  </section>
</div>
    <div class="postbit" id="37512" data-post-id="37512">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="Qqwy" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/Qqwy/120/1349_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  Qqwy
                  </h3>
		          </div>
						
			          <div class="user-title">
									<span>TypeCheck Core Team</span>
			          </div>
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>To speak from my own experience, I frequently have multiple contexts that I want to be part of the same OTP supervision tree.</p>
<p>I have started Phoenix projects with as umbrella project in the past, and I think that for most projects it does not make a lot of sense to do this when starting out. Umbrellas add an extra layer of complexity (because of the separate OTP applications) that contexts do not have.</p>
<p>But this is definitely an interesting question, as I hadn’t consciously thought of why I did one or the other before! <img src="https://forum.elixirforum.com/images/emoji/apple/smiley.png?v=15" title=":smiley:" class="emoji" alt=":smiley:" loading="lazy" width="20" height="20"></p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="37512" data-batch-url="/posts/batch_likers">
                        2
                      </span>
                      <!-- <span class="thread-count js-solved-indicator" title="Marked as solution"></span> -->
	                </div>
	                <div class="go-to-post">
	                  <a title="Go to post" alt="Go to post" href="https://forum.elixirforum.com/t/contexts-a-barrier-too-high-for-newbies/5929/110">Post #109</a>
	                </div>
	            </div>
              <div id="likers-container-37512" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="37512"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-standard-post cat-standard-post" title="Post #109"></div>
  </section>
</div>
    <div class="postbit" id="37518" data-post-id="37518">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="jeremyjh" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/jeremyjh/120/5995_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  jeremyjh
                  </h3>
		          </div>
						
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>You should really watch the <a href="https://www.youtube.com/watch?v=tMO28ar0lW8" rel="noopener nofollow ugc">introductory talk</a> by Chris - he explains you should really only consider separate OTP applications when the applications have independent storage. Contexts are intended to allow more cohesion / coupling than you’d want in those cases.</p>
<p>Speaking for myself I’m glad to see Contexts in the generators. I had found myself creating something similar on my own; I was a little dismayed when I first looked into Phoenix and saw all the database work done directly in a controller. Having it in the generator saves me a little work upfront.</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="37518" data-batch-url="/posts/batch_likers">
                        4
                      </span>
                      <!-- <span class="thread-count js-solved-indicator" title="Marked as solution"></span> -->
	                </div>
	                <div class="go-to-post">
	                  <a title="Go to post" alt="Go to post" href="https://forum.elixirforum.com/t/contexts-a-barrier-too-high-for-newbies/5929/111">Post #110</a>
	                </div>
	            </div>
              <div id="likers-container-37518" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="37518"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-standard-post cat-standard-post" title="Post #110"></div>
  </section>
</div>
    <div class="postbit" id="37580" data-post-id="37580">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="josevalim" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/josevalim/120/1787_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  josevalim
                  </h3>
		          </div>
						
			          <div class="user-title">
									<span>Creator of Elixir</span>
			          </div>
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<aside class="quote no-group" data-username="hubertlepicki" data-post="107" data-topic="5929">
<div class="title">
<div class="quote-controls"></div>
<img alt="" width="24" height="24" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/hubertlepicki/48/6822_2.png" class="avatar"> hubertlepicki:</div>
<blockquote>
<p>Contexts seem like a way to improve the code structure of application where you put everything into “web” application. Which is not something I want to do in first place <img src="https://forum.elixirforum.com/images/emoji/apple/slight_smile.png?v=15" title=":slight_smile:" class="emoji" alt=":slight_smile:" loading="lazy" width="20" height="20"></p>
</blockquote>
</aside>
<p>That’s not quite true. You can use the Phoenix --umbrella flag and have two apps: one for web and one for your domain. So you can have all of your contexts in an app with no “web” parts.</p>
<p>Also note that, if all applications depend on the same data source, such as “base” or “core”, <em>they cannot be deployed in isolation</em>. Imagine you have new migrations and you deploy a new admin which requires those new migrations. Once the migrations run, you may break the “web interface”, which is not using the new data. So in this case umbrellas may segregate the code, but the operation is still coupled.</p>
<p>In any case, umbrellas definitely have their place and if you are comfortable with them, then surely go ahead. But remember they are somewhat orthogonal to contexts (which again, is just organizing code in modules) and definitely require more discipline.</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="37580" data-batch-url="/posts/batch_likers">
                        3
                      </span>
                      <!-- <span class="thread-count js-solved-indicator" title="Marked as solution"></span> -->
	                </div>
	                <div class="go-to-post">
	                  <a title="Go to post" alt="Go to post" href="https://forum.elixirforum.com/t/contexts-a-barrier-too-high-for-newbies/5929/112">Post #111</a>
	                </div>
	            </div>
              <div id="likers-container-37580" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="37580"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-standard-post cat-standard-post" title="Post #111"></div>
  </section>
</div>
    <div class="postbit" id="37581" data-post-id="37581">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="josevalim" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/josevalim/120/1787_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  josevalim
                  </h3>
		          </div>
						
			          <div class="user-title">
									<span>Creator of Elixir</span>
			          </div>
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<aside class="quote no-group" data-username="wmnnd" data-post="109" data-topic="5929">
<div class="title">
<div class="quote-controls"></div>
<img alt="" width="24" height="24" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/wmnnd/48/4985_2.png" class="avatar"> wmnnd:</div>
<blockquote>
<p><a class="mention" href="/u/josevalim" rel="nofollow">@josevalim</a>, <a class="mention" href="/u/chrismccord" rel="nofollow">@chrismccord</a>: Why did you decide to go with Contexts  rather than umbrella applications by default? Was it the concern that going all-OTP right away might overwhelm new users?</p>
</blockquote>
</aside>
<p>To me different business applications in the same umbrella should have data isolation, otherwise they are still coupled at the operations level (see my previous comment). From that, it is easy to see that it would be overly complex if <code>mix phx.gen.html</code> generated a new app with its own database in an umbrella every time the generator is run with a new context argument.</p>
<p>Also, remember those concerns are quite orthogonal. <strong>Contexts are modules</strong>. And all applications will have multiple modules. If you want to use umbrellas, then I would have an app with all of your contexts and another for the web interface, which is exactly what the --umbrella flag does.</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="37581" data-batch-url="/posts/batch_likers">
                        4
                      </span>
                      <!-- <span class="thread-count js-solved-indicator" title="Marked as solution"></span> -->
	                </div>
	                <div class="go-to-post">
	                  <a title="Go to post" alt="Go to post" href="https://forum.elixirforum.com/t/contexts-a-barrier-too-high-for-newbies/5929/113">Post #112</a>
	                </div>
	            </div>
              <div id="likers-container-37581" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="37581"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-standard-post cat-standard-post" title="Post #112"></div>
  </section>
</div>
    <div class="postbit" id="37590" data-post-id="37590">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="hubertlepicki" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/hubertlepicki/120/6822_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  hubertlepicki
                  </h3>
		          </div>
						
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<aside class="quote group-livebook_core_team" data-username="josevalim" data-post="113" data-topic="5929">
<div class="title">
<div class="quote-controls"></div>
<img alt="" width="24" height="24" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/josevalim/48/1787_2.png" class="avatar"> josevalim:</div>
<blockquote>
<p>they are still coupled at the operations level</p>
</blockquote>
</aside>
<p>Of course they are still coupled, and of course in many cases you will deploy them at the same time. It’s nice to have functionality, however, to re-design a registration page as new umbrella app, deploy it to running system, feature toggle it or A/B test and get rid of it if works worse than previous one. It’s the stuff like this that makes this umbrealla-based architecture extremely appealing to me.</p>
<p>When it comes to contexts, it all seem to boil down to generators and what is namespaced in the context module and what not. I think good software developer would namespace their code in similar manner anyway. However, I do not see the reason to namespace modules that I consider part of application infrastructure and those are for me:</p>
<ol>
<li>
<p>Controllers, views and templates. I’m fine if these are flat layered under “Web” or whatever. It’s just the glue that takes parameters, forwards request to services layers and renders response.</p>
</li>
<li>
<p>Database-mapped Ecto modules. I generally namespace it under “Db” or “QueryDb”, “WriteDb” etc. This is also just the glue that allows one to read and write data to database.</p>
</li>
</ol>
<p>In this approach you have clear focus on what is core of your application and what not. UI is important but it’s not your business logic. Database is important but it’s not your application either.</p>
<p>I do not think that one should treat “Comment” as a database-mapped struct namespaced in context “BlogPosts”, because it’s external data, stored in table “comments”, in some external database “Db”. If we really kept that data internally, private to context - then yeah, it makes sense. But we don’t do that, most likely.</p>
<p>The reason for 1) not making sense for me is that UI will most likely diverge from and cross the boundaries of contexts anyway. The reason for 2) is actually the same, if you have single database, the queries to this database will cross contexts anyway.</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="37590" data-batch-url="/posts/batch_likers">
                        2
                      </span>
                      <!-- <span class="thread-count js-solved-indicator" title="Marked as solution"></span> -->
	                </div>
	                <div class="go-to-post">
	                  <a title="Go to post" alt="Go to post" href="https://forum.elixirforum.com/t/contexts-a-barrier-too-high-for-newbies/5929/114">Post #113</a>
	                </div>
	            </div>
              <div id="likers-container-37590" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="37590"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-standard-post cat-standard-post" title="Post #113"></div>
  </section>
</div>
    <div class="postbit" id="37613" data-post-id="37613">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="benwilson512" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/benwilson512/120/1457_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  benwilson512
                  </h3>
		          </div>
						
			          <div class="user-title">
									<span>Author of Craft GraphQL APIs in Elixir with Absinthe</span>
			          </div>
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>It’s about the organization of business logic, and it’s a lot more about writes than reads. Consider the system we have at Cargosense. We track shipments of goods, with sensors on those goods to monitor environment data.</p>
<p>Our app started pre Phoenix 1.0, and so we naturally have a models directory with quite a lot of modules. Some of these could possibly be broken into an umbrella but even with that, our core application really does require quite a few tables.</p>
<p>Core shipment operations (start, stop, etc) need to touch a variety of tables that constitute what a shipment is (shipments, environments, containers, sensor_installations). Right now there isn’t a good place for that logic to sit. It doesn’t belong in a controller, and it doesn’t belong in any one schema module.</p>
<p>What I have right now is a set of use case modules, and the code sits in one of these. The issue is that the structure of the application code doesn’t really offer any clue that <code>shipments, environments, containers, sensor_installations</code> are part of some logical unit that should be generally manipulated via the business logic in my use case module.</p>
<p>Reorganizing my existing models directory into a pod structure under contexts makes it clear where the default location is for the business logic that is responsible for the underlying tables lives.</p>
<p>Reading data from multiple contexts isn’t really a big deal. I’m in the middle of finishing some GraphQL helpers that will make this particularly easy even without the associations.</p>
<p>To your points directly:</p>
<blockquote>
<ol>
<li>UI will most likely diverge from and cross the boundaries of contexts anyway.</li>
</ol>
</blockquote>
<p>Of course! But you don’t organize your contexts on the basis of UI concerns. Pulling data from multiple contexts is completely fine. If you’re using something like GraphQL then it’s even clearer that you have internal organization, an external representation and then a mapping to go from one to the other.</p>
<blockquote>
<p>if you have single database, the queries to this database will cross contexts anyway.</p>
</blockquote>
<p>This is no longer considered problematic.</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="37613" data-batch-url="/posts/batch_likers">
                        2
                      </span>
                      <!-- <span class="thread-count js-solved-indicator" title="Marked as solution"></span> -->
	                </div>
	                <div class="go-to-post">
	                  <a title="Go to post" alt="Go to post" href="https://forum.elixirforum.com/t/contexts-a-barrier-too-high-for-newbies/5929/115">Post #114</a>
	                </div>
	            </div>
              <div id="likers-container-37613" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="37613"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-standard-post cat-standard-post" title="Post #114"></div>
  </section>
</div>
</template></turbo-stream><turbo-stream action="replace" target="load-more-container"><template><div id="load-more-container" class="load-more-container">
    <a class="load-more-button" data-turbo-stream="true" href="/topics/5929/load_more?page=12">Load more posts (56 remaining)</a>
</div></template></turbo-stream>