Girish Mahajan (Editor)

RESTHeart

Updated on
Edit
Like
Comment
Share on FacebookTweet on TwitterShare on LinkedInShare on Reddit
Original author(s)
  
Andrea Di Cesare

Operating system
  
Cross-platform

Developer(s)
  
Andrea Di Cesare, Maurizio Turatti

Initial release
  
November 30, 2014 (2014-11-30)

Stable release
  
3.0.1 / March 7, 2017 (2017-03-07)

Repository
  
github.com/SoftInstigate/restheart

RESTHeart is a Java open source Web API server built on top of the MongoDB database.

Contents

RESTHeart exposes a RESTful application programming interface with CRUD operations, following the Hypertext Application Language standard.

Motivations and Architecture

RESTHeart leverages MongoDB's document-oriented nature, creating an automatic mapping between MongoDB's internal storage of data and a graph of externally accessible HTTP resources, implementing a model of interaction compliant with an HATEOAS (Hypermedia as the Engine of Application State) representation, where the state of a client process is entirely driven by HTTP verbs like GET, POST, PUT, PATCH, DELETE, etc.

RESTHeart naturally fits an architecture where there is the need to invoke document-oriented data services on top of MongoDB via HTTP, but programmers don't want to waste time by building repetitive CRUD logic by hand.

Imagine the following scenario: you want to develop a Web application on top of a data model, following simple CRUD operations. Data can be modeled as a hierarchy of documents, and MongoDB is a perfect fit for the job, or you already have some data in a MongoDB instance and you want to quickly build a user interface for it.

RESTHeart allows to deploy and run specialized, independent micro-services and it's already available via Docker containers.

Technical implementation

RESTHeart it's fully implemented in Java 8 and embeds Undertow, the non-blocking HTTP server which is one of the core components of the Wildfly Application Server.

Undertow is a flexible performant web server written in java, providing both blocking and non-blocking API’s based on NIO. Undertow has a composition based architecture that allows you to build a web server by combining small single purpose handlers. The gives you the flexibility to choose between a full Java EE servlet 3.1 container, or a low level non-blocking handler, to anything in between. Undertow is designed to be fully embeddable, with easy to use fluent builder APIs. Undertow’s lifecycle is completely controlled by the embedding application. Undertow is sponsored by JBoss and is the default web server in the Wildfly Application Server.

The multi-threaded process connects to a MongoDB server and exposes its data as operations, via a RESTful interface over the HTTP protocol, so that data clients can interact with the DataBase Management System without the need of a low level database driver.

MongoDB resources such as databases, collections, documents are automatically represented with the Json variant of the Hypertext Application Language.

RESTHeart inherits the same Undertow's pipeline architecture, where specialized handlers are chained together to serve the requests. In order to provide additional application logic, custom handlers can be bound under the /_logic URL.

RESTHeart also supports MongoDB's GridFS and allows for storing and retrieving large binary files via HTTP.

Sitting in between the client and the database, RESTHeart also provides gateway services, such as Authentication and Authorization, data Transformation and Validation.

References

RESTHeart Wikipedia