Greenius ClojureScript integration and roadmap

There are three basic ingredients to take care of our brains: exercise (walking is enough), social contact (we are humans by the relationship with others) and intellectual exercise, to do something challenging, different. Certainly the adoption of the Clojure stack forces us to stay sharp – simplicity demands to think.

ClojureScript integration in plot editing tool

As you already know, our back-end code is entirely built with Clojure and Datomic and now, thanks to Jonas Enlund, we have our first ClojureScript + OM component. Since last week Greenius users have an improved Plot edition tool, with new features like undo/redo, zoom and -coming very soon- multi-plot option.

Jonas has used the Flux pattern to build the architecture and these libraries:

:client {:dependencies [[org.clojure/clojurescript "0.0-2498"]
[org.clojure/core.async "0.1.346.0-17112a-alpha"]
[org.clojure/tools.reader "0.8.13"]
[org.om/om "0.8.0"]
[prismatic/om-tools "0.3.10"]
[cljs-ajax "0.3.3"]]

GreeniusPlotGrid

 

The new plot has been smoothly embbeded in our Enyo based UI via iframe in an Enyo component.

 

The result is a powerful grid edition tool for our users, and for us, the foundation for the next Clojurescript based component in our Roadmap: an integration with plant sensor Koubachi where we will display real-time visualization of data in charts/graphs.

 

newplot

Greenius Roadmap

We are currently working on designing and developing some very exciting new features for Greenius:

Plot edition

Just released in the beginning of February, it’s a huge improvement on the plot editing functionality. This new development opens the door for the multi-plot feature in the future.

Shop

We will add a curated shop to the platform, with selected products from independent retailers. We hope to publish it by the end of February 2015.

Koubachi

Our first sensor integration! We will make it possible to connect your Koubachi plant sensor to our platform offering real-time and historic data visualization as well as customized plant-care suggestions.

Follow topics and interests

This feature will enable users to follow gardening and green lifestyle topics of their interests, complementing the capability of following other gardeners and specific plants.

 

——————————————————————-

 

Lots of exciting work ahead to build a useful and meaningful platform that will contribute to create a greener future and in the way, help us keep a healthy and sharpened brain with the Clojure stack!

 

Greenius: Our tech roots.

One of the most fascinating things one can do in life is to build things: friendships, a family, a backyard garden, a company or a software. This post explains how we came up with the software we have built with our hands and tools in Greenius.

 

A year back when we came up with the Greenius idea Iván showed me the potential of the Clojure stack. First, I was overwhelmed due to my heavy investment in OO approach and technologies during my career. Secondly, suspicious about a LISP dialect which I thought was not pragmatic enough for our startup; and finally, I felt somewhat sluggish about learning a completely new functional language. Iván, with sensible patience as always, kept sending me information about Rich Hickey’s creature and after a few days I was hooked. We decided to join the Clojure gang.

 

In this post I will layout the basic architecture, the ingredients we have used and the main reasons I am glad we chose these tools.

 

Greenius consists of three main technologies: on the client side a JS framework called Enyo that produces HTML5 code behind the scenes and, on the server side, the Clojure stack: Clojure language and the Datomic database. The following diagram shows the different components of Greenius’ technology stack:

 

Greenius technology stack

Enyo helps us create a rich client -interactive- web application and we have mixed it with Pure CSS to easily design responsive layouts (this mix has caused cross-platform compatibility problems in some mobile devices that we are investigating as we speak).

 

HTML5 apps have considerably improved performance lately and Enyo allows us to write a single app for all devices and -modern- browsers. For Greenius we wanted a simple and clean design so we have used LESS to build the theme for the UI.

 

Maybe you are thinking why after my passionate words about Clojure we haven’t chosen ClojureScript to build the front-end. The quick answer is that we think that we will eventually migrate to it, but our own timing plus Enyo’s compelling value proposition (open source, cross-platform, extensible, fast, lightweight,…) made us take this decision.

 

Greenius’ true power resides on the server. Iván, after several days figuring out the Datomic API, designed a software (influenced in large part by Amit Rathore’s design) with just immutable data structures and pure functions (with much less code than traditional OO languages) allowing us to focus on our core business requirements rather than inherent technological problems. Simple but not simpler.

 

We are at the moment using the Free version of Datomic as we have just launched (no problems so far!), but we plan to upgrade to Datomic Pro Starter as soon as it is necessary.

 

API, Service, Domain, etc. are namespaces that contain small functions that do one thing and always return the same answer given the same arguments, so no debugging is needed (phew! – we can’t anyway). Functions are run and tested on the REPL (our IDE is Eclipse + counterclockwise. That’s right, we’re not using Emacs).

 

Finally, communication between client and server is an exchange of these data structures using JSON format. In Enyo we submit web requests with Ajax and in Clojure we use Ring for request and response plumbing and Compojure for routing.

 

Greenius is a work in progress and as anything worthwhile, will remain so. We continue to improve it but, unlike most of the software that I have developed and maintained in the past, Greenius continues and will continue to be manageable thanks to Clojure. This will consolidate and guarantee Greenius’ evolution and scalability. Not bad considering that we are using functions that just perform data manipulation.

 

If this stack has caught your imagination and want to know more here are some links to feed your brain:

 

Clojure

http://clojure.org/
http://www.infoq.com/clojure/
http://www.braveclojure.com
http://www.flyingmachinestudios.com/
http://www.clojureatlas.com/
http://www.clojuresphere.com/

 

Datomic

http://www.datomic.com
http://www.datomic.com/videos.html
http://docs.datomic.com/

 

Enyo

http://enyojs.com/

 

Pure CSS

http://purecss.io/