Posted on by & filed under Content - Highlights and Reviews, Programming & Development.

codeA guest post by Lenny Markus, who has been involved in technology in one way or another over the last 15 years. He is a problem solver at heart and has spent the last two years at @PayPal working on a variety of interesting challenges, trying to find elegant solutions that make life easier for others. He always mentors and try to raise the bar for everyone around him. He can be reached at @lennymarkus.

Life before Kraken

When PayPal decided to use Node.js as a development stack, we quickly realized that it was not going to be all rosy. As a large company we have a varied line of products, that are created and supported by thousands of developers, and distributed globally. This is quite different from a smaller company (think of a start-up), with a small and tight development team that only needs to focus on a single product.

Large companies have different needs, and in our case, consistency across applications would prove to be a big one. Existing Node.js frameworks were not providing enough structure to projects, particularly as they grew larger. Over and over we’d see teams reinventing the wheel, trying to establish their own unique set of patterns, and slowly drifting away from the way others did things.

Kraken grew out of a need for consistency across projects at PayPal, but very quickly evolved beyond that.

Is it a framework?

Let’s make this clear from the start: Kraken is not a framework. It’s a configuration and conventions layer that gives structure to the well known ExpressJS application framework. Instead of reinventing the wheel, or trying to hide ExpressJS from the developer, Kraken manages the organizational aspects of the application. The benefit of this is that developers already familiar with ExpressJS don’t need to spend a lot of time learning a new technology stack. A new hire can quickly jump on a project and be productive right away.

So how does this organizational aspect come into play? If you look at a typical ExpressJS app, all of the configuration and routes tend to be bundled into a single place. This is fine for small applications or rapid prototyping, but when your project needs to expand, things can grow messy very quickly. Kraken lays down a foundation for your project in which route controllers, models, templates, and content bundles are kept separate from one another.

This might create some slight overhead for tiny projects, but it pays off as soon as your project becomes larger. Debugging and maintainability are easier when you are managing smaller chunks of code.

What else can Kraken do for me?

Organization is just the beginning. Kraken bundles together a few other modules that provide additional functionality.

Internationalization: Managing multiple languages in an application is a burdensome task. PayPal provides services to 193 countries, so Kraken had to make it easy for our developers to handle this. By smartly leveraging content bundles and dust templates, Kraken applications have built-in support for internationalization; so rather than grafting it in as an afterthought, developers can create their applications the right way, on the first pass.

Security: During development it’s very easy to forget applying basic application security best practices. The Kraken suite includes a module called Lusca. This module is deployed as middleware, and provides support for Cross-Site Request forgery tokens, frame policies, as well as HTTP Strict Transport Security, Content Security Policy and privacy policies. The beauty of Kraken is that all of these are configured, and enabled out-of-the-box, so a developer can jump straight to writing the application, without having to worry about these simple, yet critical steps.

Development speed: Similar to Rails, Kraken has a code generator, built with Yeoman. This generator allows developers to quickly create scaffolding for different parts of the application. For example, if a new page needs to be created, by simply typing a command with this tool (yo kraken:page myPage), a full set of controllers, models, templates, content and even unit tests will be created, saving the developer from what is typically grinding work.

Is Kraken the silver bullet for Node.js development?

No! Kraken is not the ultimate solution for every use case. We built Kraken in order to solve our particular set of problems, however, many of these are not unique to PayPal. Any company with a large number of developers or products that’s using (or thinking about) Node.js, is probably going to run across some of these along the way. If this sounds like your company, you should consider trying Kraken out.

Bonus question: Why the decision to open source it?

We set the Kraken free because we love it :).

While not originally intended for open source, when Kraken was built, it was intentionally kept free of customizations that would make it specific to PayPal. This was done intentionally, in order to keep it closely aligned with open standards. Kraken’s predecessor was written in Java, and based on Spring. While it provided many PayPal-specific facilities and benefits, it presented new developers with a very steep learning curve, and a lengthy training/ramp-up process before they could become productive. The more it diverged, the more challenging this became.

From this experience, it was clear that the best way to keep Kraken alive, useful and relevant was to release it to the open source community. After polishing up the documentation and setting up our awesome home page, the project was released to the public in November of 2013. So far it’s been starred by over 2,000 developers and has a healthy following on Twitter @kraken_js.

The development of Kraken is ongoing and fully out in the open, as are all the issues, questions and bug reports. PayPal is just one more customer, and builds from npm install kraken-js just like any one of the thousands of people that have already started using it.

Coming up next

In the next post, I will take a deeper dive into the structure of a Kraken application, and walk you through a simple Hello World example. You will learn how the application logic, views and content are separated, and the best practices for setting up your Kraken application.

Look below for some great Node.js books (that also contain ExpressJS) from Safari Books Online.

Not a subscriber? Sign up for a free trial.

Safari Books Online has the content you need

Node.js Recipes: A Problem-Solution Approach is your one-stop reference for learning how to solve Node.js problems. Node.js is the de facto framework for building JavaScript-powered servers. You will first be introduced to this exciting technology and what it can do, then learn through comprehensive and easy-to-follow recipes that use a problem-solution approach. Node.js Recipes teaches you to fully utilize the Node.js API, and leverage existing modules to build truly exciting projects.
Node.js in Action is an example-driven tutorial that starts at square one and guides you through all the features, techniques, and concepts you’ll need to build production-quality Node applications. You’ll start by learning how to set up your Node development environment, including loading the community-created extensions. Next, you’ll run several simple demonstration programs where you’ll learn the basics of a few common types of Node applications. Then you’ll dive into asynchronous programming, a model Node leverages to lessen application bottlenecks.
Instant Node.js Starter begins with the installation of Node.js and then shows you how to create your first Node.js HTTP server. You will learn how you can use the callback pattern and EventEmitter to control the asynchronous flow and the power of Node.js streams to make your application more scalable and responsive.

Tags: ExpressJS, Kraken, Lusca, Node.js, Rails, Yeoman,

One Response to “Why should I use Kraken?”

  1. Dejan Glozic

    Hey Lenny,

    Thanks for a great article. BTW we met during the NodeDay 2014. I am writing a blog post on Kraken.js and reviewing it for our possible use in IBM projects. I am puzzled about the claim that it not a framework and express.js is not hidden. How do I get access to express server? Many libraries (e.g. are written to co-exist with express. has use cases on their web site piggy-backing on the server and reusing the port. How would you do that with a Kraken app?

    Regards, Dejan