myplanes is a webapp I built to get notified if an interesting plane was heading towards the Wrocław airport. I wanted to be notified as early as possible so that I could drive to the airport and see it landing, ideally right above my head.
The idea is that the app is configured to scan the sky around particular coordinates. If a plane appears in the scanned area, a push notification is sent to the subscribed devices. The app scans the sky at a constant interval of 1 minute.
The scan is configured with the following parameters:
coordinates- the point to scan around
range north- how many kilometers north should be scanned
range east- how many kilometers east should be scanned
range south- how many kilometers south should be scanned
range west- how many kilometers west should be scanned
altitude threshold- how low [kilometers] should the plane be to be considered for a notification
Basically, the app takes into account a rectangular area of the sky around the specified coordinates.
There’s also a very basic Web UI which shows the flights discovered by the most recent scan.
The application uses OpenSky Network API as the data source for live flight data.
Good and bad at the same time.
- The notifications are coming in as intended. I used web push and they are working fine on Windows and Android, but not on iOS which I’m using daily.
- Turns out that OpenSky Network API does not really get much data from around Wrocław. The app works perfectly if I set the scanning area e.g. to Frankfurt - their coverage there is just fine.
The app works, but it is basically useless in Wrocław.
I decided to experiment a bit with the tools. Instead of using an SQL database I decided to use:
- Redis for storing the data about the airplanes and about the discovered flights;
- Firestore for storing the data about the devices subscribed for push notifications and configurations of the scanner.
The tech stack for the app
Kotlin + Micronaut, React.
I use an ansible playbook to set up the VM with JDK and Redis. It also sets up the application to run as a service.
The fun stuff
Finding the bounds for the sky scanner
I used some mathematical formulas for calculating a destination point given the distance and direction. I’d say it’s not a technical achievement, but - still - it was interesting to find out how to do it and read about it.
At the time I wrote the code (2020), WebPush was working just fine everywhere besides iOS (not sure about macOS though).
- letting the Java application deal with SSL certificates feels totally unnecessary; it would be much easier to have e.g. an NGINX running in front of the app to deal with them and run the app itself with HTTP only;
- although at first I thought it’ll be super simple to just run the app using
java -jar ...and also run
redisdirectly on the VM, it turned out to be quite cumbersome to manage all the dependencies needed in the OS - Docker would make the deployment much more simple;
- at least for such a small project, having the frontend and the backend on separate servers is very unnecessary; the amount of config needed to run the app is much bigger than if I was simply serving the static content from the backend app;
- I guess it’s good to test your data source before you dive into the implementation around it;