Planning a NodeJS backend architecture for the RoadStar project

After evaluating the task of creating a backend for storage of measurement and gps data and displaying it on a map, it is time to think about how to put the pieces together.

What we want to use

  • MongoDB for storage
  • GraphHopper/mapmatching for matching the measured position of the GPS sensor to the nearest street
  • Express/NodeJS API enabling access to the stored data from the outside
  • Leaflet for displaying the data on a map
  • GPS and gyro sensors on a Raspberry Pi

MongoDB allows us to store the JSON which contains the measured data as is. This comes in handy, because no conversion needs to be done internally. But wait… The GraphHopper only accepts data in the gpx format, a XML standard for storing geo data. And there also is Leaflet, which works best with GeoJSON, another predefined standard, this time JSON again. This problem of different data formats can only be solved by creating and/or using existing converters. This adds another piece to our architecture, the

  • custom converter

Having all these pieces and different formats, the need for a first overview arises. After sketching and refining, i came to the following concept:


A first concept of an architecture

The next steps will be creating some of the parts and check whether this architecture will stand the test 🙂

REST API for Roadstar Project

The Roadstar Project requires a REST API for storing and accessing the measured data on a separate server.

Using NodeJS, MongoDB and the Express Framework, setting up a server stack is relatively easy. Express enables easy routing of API requests as well as easy integration of various middleware for purposes such as validating requests and much more. Due to MongoDB’s non relational nature we can then easily store the retrieved JSON measurements directly in the database.

Using mocha and chai for TDD, testing the API endpoints and controller functions allows us to verify the functionality.

The first app skeleton, controllers and models are created from previous projects, but could also be scaffolded with the popular Yeoman.