IV - biking2
By Michael Simons.
biking2 or “Michis milage” is primarily a web based application for tracking biking related activities. It allows the user to track the covered milage, collect GPS tracks of routes, convert them to different formats, track the location of the user and publish pictures of bike tours.
The secondary goal if this application is to have a topic to experiment with various technologies, for example Spring Boot on the server side and AngularJS, JavaFX and others on the client side.
As such biking2 has been around since 2009 and in it’s current Java based form since 2014. Defining production as full filling the primary goal it’s been in production ever since.
The project is published under Apache License on GitHub, use it however you like. Though I’ve been blogging regularly about this pet project, the documentation in its current form was created after I met Gernot and Peter at an awesome workshop in Munich.
IV.4 Solution Strategy
At the core of biking2 is a simple yet powerful domain model based on a few entities of which a “Bike” and it’s “Milage” are the most important.
Although data centric, the application resigns from using too much SQL for creating reports, summaries and such but tries to achieve that with new Java 8 features around streams, lambdas and map/reduce functions.
Building the application with Spring Boot is an obvious choice as one of the main quality goals is learning about it. But furthermore using Spring Boot as a “framework” for Spring Framework allows concentration on the business logic. On the one hand there is no need to understand a complex XML configuration and on the other hand all building blocks are still put together using dependency injection.
Regarding dependency injection and testability: All injection should be done via constructor injection, setter injection is only allowed when there’s no other technical way. This hopefully prevents centralized “god classes” that control pretty much every other aspect of the application.
Spring Boot applications can be packaged as single, “fat jar” files. Since Spring Boot 1.3 those files contain a startup script and can be directly linked to /etc/init.d on a standard Linux systems which serves TC4.
Interoperability will be achieved by using JSON over simple http protocol for the main API. Security is not the main focus of this application. It should be secure enough to prevent others from tempering with the data, confidentiality is not a main concern (read: passwords can be transmitted in plain over http).
The internal single page application shall be implemented using AngularJS. The deployable artifact will contain this application so there is no need for hosting a second webserver for the static files.
For real time tracking the MQTT protocol will be used which is part of Apache ActiveMQ, supported out of the box by Spring Messaging.
Graphing should not be implemented here but instead the Highcharts library should be used. The configuration for all charts should be computed server side.
IV.8 Cross-cutting Concepts
Domain Models
biking2 is a datacentric application, therefore everything is based around those entities that manifest as tables.
Tables
| Name | Description |
|---|---|
| bikes | Stores the bikes. Contains dates when the bike was bought and decomissioned, an optional link, color for the charts and also an auditing column when a row was created. |
| milages | Stores milages for a bike (when and how much). |
| tracks | Stores GPS tracks recorded and uploaded with an optional description. For each day the track names must be unique. The columns minlat, minlon, maxlat and maxlon store the encapsulating rectangle for the track. The type column is constrainted to “biking” and “running”. |
| assorted_trips | Stores a date and a distance on that day. Multiple distances per day are allowed. |
| locations | Stores arbitrary locations (latitude and longitude based) for given timestamp with an optional description. |
| biking_pictures | Stores pictures collected from Daily Fratze together with their original date of publication, their unique external id and a link to the page the picture originaly appeared. |
| gallery_pictures | Stores all pictures uploaded by the user with a description and the date the picture was taken. The filename column contains a single, computed filename without path information. |