Rob Novelino
January 9, 2017
<p>Here at Vinta we believe that programmers, not processes, nor code, are the most important assets on software engineering. Due to that, we believe in using every tool available in order to facilitate our programmers' lives. One of our favorites is our boilerplate. If you are unfamiliar with the concept, a boilerplate is "any code block that is reusable in new contexts with minimal alteration". In this post, we will show you guys some examples of famous boilerplates, why we did our own, and how it looks so far, so you feel comfortable with using it or editing it to fit what you need.</p><h3 id="famous-boilerplates-around-and-why-to-use-them">Famous boilerplates around and why to use them</h3><p>You probably have already seen some boilerplates around, it can be the simplest bits of code or even a default project template for Django. They are all templates, and it's easy to see their advantages. On this lower level of complexity, they are good to guarantee coding standards across projects. But you can check more complex ones like the <a href="">HTML5 boilerplate</a>, the <a href="">Cookiecutter Django</a>, the <a href="">Django Hackathon Starter</a> or even <a href="">Vinta's boilerplate</a> (which comes with a whole set of facilities we will discuss in a moment). These bring even more advantages to the table such as a speed-up on the initial project.</p><h3 id="how-about-building-your-own">How about building your own?</h3><p>We believe that the best solution still is to create your own boilerplate, besides increasing the benefits already listed here, you'd also get:</p><ul><li>a Full-stack solution custom-fit to your environment</li><li>an easy way to create and maintain guidelines for your projects company-wide</li><li>reduced errors</li><li>keep the project template updated</li></ul><p>the idea behind making your own boilerplate is simple: no one knows the needs of your company better than you. So the first thing you should do in order to build your own, first write down and discuss around the company "what should all of our projects have in common?". This list can go from email sending to VR integration but it's really important to get a list of what are common needs among the projects in your company.</p><p>Here is a list of what we thought necessary here at Vinta and the technologies we chose for those needs:</p><ul><li>Backend Framework (<a href="">Django 1.10</a> and <a href="">Django.js</a>)</li><li>Email Sending (<a href="">Sendgrid</a>)</li><li>Responsive Styling (<a href="">Bootstrap Alpha 4.2</a>)*</li><li>Periodic Jobs (<a href="">Redis</a> and <a href="">Celery</a>)</li><li>Interactive UI (<a href="">React</a>)</li><li>Continuous Integration (<a href="">CircleCI</a>)</li><li>Handling Static Assets (<a href="">Webpack</a>)</li><li>Static Files Serving (<a href="">WhiteNoise</a>)</li><li>Database (<a href="">PostgreSQL</a>)</li><li>Easy Deployments (<a href="">Heroku Button</a>)</li><li>Logging (<a href="">Papertrail</a>)</li><li>Performance Monitoring (<a href="">Opbeat</a>)</li></ul><blockquote>As you can notice, we use the Alpha version of Bootstrap 4, we strongly encourage you to use it instead of Bootstrap 3, there is a huge list of improvements, for us the best thing is that it got way easier to customize elements and that opened a lot of design options. You can check other advantages <a href="">here</a>.</blockquote><h3 id="vinta-boilerplate">Vinta Boilerplate</h3><p>To show you how easy it gets with your own boilerplate, here is the actual structure of a project using Vinta's boilerplate:</p><figure class="kg-card kg-image-card"><img src="" class="kg-image" alt="Alt text"></figure><p>To start coding is easy. Most people don't know that the <code>django-admin startproject</code> command can receive arguments to open on a specific boilerplate, so just use the command <code>django-admin startproject theprojectname --extension py, yml, json --nameProcfile --template=</code> then check for dependencies using these lines:</p><pre><code>&gt;&gt;&gt; pip install -r requirements-to-freeze.txt &gt;&gt;&gt; pip freeze &gt; requirements.txt &gt;&gt;&gt; npm update --save &gt;&gt;&gt; npm outdated </code></pre><p>Update everything that was flagged as outdated, change the first line of README to the name of the project.</p><p>The last step would be to set up the migrations, as follows:</p><ul><li>Create a copy of <code>/settings/</code> in <code>/settings/</code></li><li>Create a .env file in the root of the project and add <code>DJANGO_SETTINGS-MODULE=".settings.local"</code> to it</li><li>Create the migrations for <code>users</code> app: <code>python makemigrations</code></li><li>Run the migrations: <code>python migrate</code></li></ul><p>After you start coding, one of the biggest perks is using CircleCI. As said above, we use it for continuous integration, for those who don't remember, continuous integration is: "The practice of merging all developer working copies to a shared mainline several times a day." and that requires a high level of automation with tools, as well as a internal habits to deploy minimal amounts of code. Down here is how a deploy looks like with CircleCI for us. You can check more about the subject <a href="">here</a>.</p><figure class="kg-card kg-image-card"><img src="" class="kg-image" alt="Alt text"></figure><p>if you have any doubts be sure to comment down below and check out the other posts on our <a href="">blog</a>!</p>