The Nuxeo Platform is a powerful content management system and sometimes with great power comes (great) complexity, especially in terms of user interface! Complex user interfaces are often a part of our customers’ project requirements and the Nuxeo Platform can easily provide a highly customizable UI with complex capabilities. But recently, the University of Orléans (in France) was looking to build a web application with a simple user interface that has a basic set of actions for its users (students, professors, etc.) and they chose the default user interface of the Nuxeo Platform!
We have invited guest blogger, Kevin Frapin, from the University of Orléans to share the story of how Nuxeo found its place among the university’s web applications for its users and how this web application was built. Here is his story!
KISS - Keep It Simple, Stupid
The University pointed out that the users wanted a really simple user interface to interact with the platform with a basic set of actions available - in short, a “Dropbox-like” web interface.
That interface was built and deployed in January 2015 at the University. The main capabilities of this “Dropbox-like” interface are :
- Basic and CAS Authentication
- Document import and download
- Folder creation
- Folder sharing
- Document copy, cut and paste
Here are some screenshots of the web application that was built:
The Application Architecture
After some thought, we decided to use the Nuxeo REST API to build this web application.
However, it appeared that direct Nuxeo API requests from the browser to the Nuxeo Platform were not the best choice for us. That’s because:
- We preferred to control the granularity of the the exposed API
- The web application had to have some interactions with other systems (see the schema below)
So, we decided to create a proxy server exposing a new minimal REST API to the final users, and to make the Nuxeo REST API calls from that proxy server.
This decision led to the creation of a three-part architecture :
- The client side web application
- The server side (proxy) application
- The Nuxeo Platform
We will essentially focus on the server side proxy here and explain how we built it on top of the Nuxeo REST API using a NodeJS server acting like a proxy server.
NodeJS exposing a new REST API
The proxy server could have been developed in multiple technologies, but we decided to use the NodeJS technology to implement it. The main reasons behind choosing this technology were:
- The capability to easily expose a minimal REST API between the user and the proxy
- The capability to easily transform and filter the response of Nuxeo Platform to send it to the user
- The capability to cache data and save some Nuxeo REST API calls
- The capability to put business logic in the proxy server
- The scalability of NodeJS
The final reason that convinced us to use the NodeJS technology was the NodeJS module[1] developed by Nuxeo. Nuxeo has published a flavor of their Nuxeo JavaScript SDK as a NodeJS module ready to use.
The Nuxeo JavaScript SDK has been created to facilitate calls on the Nuxeo REST API by providing method wrappers such as document.create, document.fetch, etc.
The Server Application
After the beginning of development, we soon discovered that the Nuxeo JavaScript client was not fully ready to respond to our needs. That was why we decided to fork it on GitHub, and make some enhancements to it.
The main enhancements that we made were :
- The wrapping of new documents methods for easily coping and moving documents
- The addition of the proxy and portal authentications
Those enhancements were contributed as pull-requests and accepted.
Once these enhancements were done, we quickly developed the server side application. This made it possible to realize the following actions on Nuxeo (through the REST API):
- Authenticate a user via basic, proxy and portal methods
- Import one or multiple document(s) from users to the Nuxeo server
- Download document blob from the Nuxeo server to users
- Create new folder(s) on Nuxeo
- Share folders between users
In addition to these Nuxeo interactions, some additional business interactions have been added giving the server side application the capability to:
- Authenticate users on CAS server and Nuxeo
- Communicate with MongoDB databases and LDAP
- Send mails to users
- Put and retrieve data in Redis cache
Why Use Nuxeo Module for NodeJS (aka Nuxeo JavaScript Client)?
Having played a lot, during the last months, with the Nuxeo module for NodeJS, we can say that this module should be considered as a serious client for interacting with Nuxeo.
Indeed, this Nuxeo REST API client has a lot of assets and developers interacting with the Nuxeo platform should consider the use of this module in their future developments. The reasons for this are many!
- Simple and comprehensive module
- Fast code writing and deploying on NodeJS
- Fast code executions on NodeJS with asynchronous calls
- Optimizations available on NodeJS (parallel calls, Redis cache, etc.).
To conclude, I can say that there are many other kinds of applications that could use the Nuxeo module, not just web applications. For instance, we can use the Nuxeo module for applications that require a lot of document processing (like batch). The possibilities are endless and you are most welcome to find out for yourself!
[1] https://www.npmjs.com/package/nuxeo and sources available on Nuxeo GitHub account: https://github.com/nuxeo/nuxeo-js-client/