Tuesday, April 26, 2016

JHipster Notes

JHipster.  I have always been a big fan of using framework / code generators to kick start apps where you just want to get something done but don't want to spend a lot of time laying in infrastructure and UI. In the past I have always used Grails for this purpose to pretty good effect. I have lots of utility apps that do a specific thing that, well, look a lot like a Grails app. This really allows me to quickly dive into the thing I wanted to get done. I was recently introduced to another project, JHipster, that uses code generation rather than a framework approach to kick start an application. Whereas Grails provides an application framework with a rich plugin architecture, JHipster takes the approach of generating your app from a BUNCH of best of breed technologies that would be needed in an enterprise web app.

What is it? At its core it pulls together Spring Boot on the back end and AngularJS on the front to create a modern looking application using tried and true enterprise architecture choices throughout. I won't include the laundry list of technologies within the generated app, but the highlights for me are the AngularJS/Bootstrap generated front end, Spring Boot using Spring Security and JPA with Spring Data JPA.

Javascript. I have been working on a largish sized AngularJS application at my full time job and have come to appreciate the size of Javascript/NodeJS ecosystem involved in standing up modern JS applications. JHipster takes full advantage of that ecosystem by generating a front end application that is in line with what a front end developer would expect. JHipster uses Yoeman, a fairly well known javascript code generator, to generate the application. Javascript dependencies are managed by Bower and you get a choice of Gulp/Grunt as your front end build tools. On my Macbook Pro I tend to have node versioning issues when using a lot of these tools, so I have installed NVM (Node Version Manager) to keep node under control.

Build. On the java side, you have a choice of build tools, Gradle or Maven, for the overall build.
 As this is a Spring Boot app, the java build tool is the main method for rendering the entire application, but it defers to the javascript build where it needs to.  The generator has you make this choice up front and I picked Gradle and Gulp for my build tooling.

Docker.  As of late I have also been playing with Docker to learn about quickly spinning up deploy environments.  JHipster generates a Docker directory in the src directory to provide the container set to deploy your app into.  In my case JHipster generated docker config for a java container and a postgresql container.  There was a bit of mystery for my around the postgresql container until I dug into it.  How did it know the db name, user name, password?  Where were all the commands necessary to create these things?  It turns out that the image that JHipster uses for Postgresql container, documents that you can just pass the user name as an environment variable on startup and it will use that to create the user, db, and password for you.  In my case the user name is simply my application name.

More to come.  I plan on using this blog to document the issues I come across as I take my JHipster generated app into a real working application that actually does more than CRUD. Topics I want to address in future blogs are Liquibase, SSL, JHipster Domain Language.

No comments: