Say hello to the Slush generator

by Jen Breese-Kauth

MarkLogic's Vanguard team has built a plugin for the Slush generator, which is available from GitHub and NPM. Slush provides a generic framework using a three-tier architecture to perform scaffolding tasks using Gulp.  The Vanguard Team uses Slush to ramp up a new project folder with a single command. It creates a REST-type MarkLogic Roxy project for you; copies a Node.js/AngularJS stack on top of it; and runs some initialization commands for you; all in a single command.

You might ask, why a stack using AngularJS, Gulp, Node.js, etc.? The main answer is pretty straight-forward: it matches our customer's desire for MarkLogic to be part of three tier applications. As of version 8, MarkLogic supports native, server-side JavaScript; natively stores JSON; and provides a Node.js client to interact with a vastly extended REST API.

The MarkLogic Engineering team built an application called Samplestack using the same components. The most important difference between Slush and Samplestack is that Samplestack provides a static fully-fledged demo application, while the Slush plugin is a base template, a toolset, and a set of readily available components.

JavaScript has become popular in all kinds of areas. It was originally used most to make websites dynamic in browsers on desktops, but mobile development has increased its popularity. Recently, it also became a popular server-side language, driven in part by developers' embrace of the convenient JSON data-interchange format. Node.js, used by this generator, is now a very popular server-side language. Gulp, which runs on Node.js and which this generator relies on, is a very popular tool for JavaScript-oriented development tasks.

And finally: AngularJS. JQuery has been pretty popular over the past decade or so. It is a powerful tool but it doesn't blend in very naturally with HTML and it doesn't provide an MVC-like separation of concerns. AngularJS is the first to bring JavaScript and HTML back together but without the need to do inline scripting. Instead, it allows blending in dynamic behavior and functional components by adding mere attributes and elements. It encourages developers to break down code into reusable components and provides good means to write a web application with an MVC model in mind.

Details about the Stack

The stack we are using consists of three layers:

Even though this can be technically seen as a three-tier solution, the middle-layer is mostly serving as a proxy between front-end and back-end. There is currently no business logic in the middle-layer, which was a deliberate choice to keep the architecture simple. Based on the way it works, it might be better to describe this as a two-tier solution. However, nothing stops you from moving business logic into the node-layer, effectively separating application logic from business logic, and maturing the middle-layer into a proper middle-tier. Slush is a POC (proof of concept) tool because building a production application with a pass-through middle tier would have the same security problems as exposing an ODBC connection to end-users.  In this way, the generator is like Application Builder -- a great way to get started quickly, but remember to address security before launching.

Comments