As an intermittent user of FDDB.info I have logged my consumed meals for quite a while in a mobile application each day. However as all graphs and analytics data can only be used by paying premium members of the application and I wanted to create dashboards using Grafana for my data, I was looking for a way to retrieve all the data from the website and save it in my own database. Thus a little program was born, called FDDB Exporter. This is a simple Java backend service which connects to FDDB.info, scrapes the HTML for all the data I want and then saves the data in my own database. To have an automated retrieval of the data I designed the application to run every night and scrape the data entered the day before, so I don’t miss anything. As it turns out, I am indeed not perfect and I happen to forget to enter data (sometimes even the entire day) which results in the recent days data not beeing retrieved in the night. Foresighted as I am, I created an endpoint to use with an HTTP POST request with a payload of the timerange to export, so I can export the data for a few missed days easily. However I do not want to open a HTTP client retroactivly entering the missed dates every time. Through this minor inconvenience an idea was born: a mobile application shall rise and solve this problem once and for all! Of course it would be far easier to just have another endpoint in the backend service to solve my issue, but that wouldn’t be as fun, right?
less talk-y, more show-y
For all the impatient individuals like myself out there, this gif shows what I created. If you want to see the code yourself just follow the Github link underneath the gif.
more details of the backend please
The idea of the app is quite simple. I extended the API of the backend service and created an endpoint which receives a
GET request with 2 query parameters. I specifically chose
POST since there’s no real payload and the call is idempotent (and it is easier to implement). The first query param is the amount of days back I want to re-export. As it happens that I miss a couple of days at a time, this is a better idea than just retrieving yesterday. Obviously this is only working as long as I can remember the meals I consumed days back, but that’s not the point. A second query param is a boolean to include today in the data of the export. This is a rarely used feature for me, but when analyzing data it might be interesting to include the current day. The endpoint is described here.
what about Flutter now?
Well, the Flutter application is just making a request to the endpoint mentioned above and the backend returns a json of the data exported. This is absolutely not necessary but this is about making things look cool and having literally nothing except “it worked, yay” after pressing the button is just sad. So the design of the app is quite easy, we just need a single view, an input field for the days to export, a checkbox if today should be included and a button to send the data to the backend. Beneath these controls the results of the backend call should be displayed.
Why did I choose Flutter? My colleagues told me it’s cool and easy and I thought: why not? It is indeed cool and easy, although as a predominant Java developer it does feel quite foreign. However as most things in IT it’s absolutely possible to get a hang of things when enough time and Google searches are put in. I’m quite new to Flutter and this is my first app ever created with it. I’ve tried my best to structure the code following best practices but please give me your thoughts if you are more experienced in this.
A word of warning:
hot reloading in Android Studio did not work for everything and just restarting the app may save you a lot of time wondering what went wrong. The tooling of Flutter is quite impressive and really helps getting things started and getting things done. Building the final apk to use on Android is as easy as typing
flutter build apk. As I am still quite new I assume most issues I dealt with are my fault. If this motivates you to get started with Flutter, visit the Getting Started page, install the SDK, your IDE and the necessary dependencies. To build this app yourself you only need to change the endpoint in the config file to link to your hosted backend service, as mentioned here.
In the meantime I will rest easy knowing I can just re-export any missed days of data entry by the press of a button in my own app.
To conclude things a haiku written by ChatGPT:
In gentle breeze it flows,– ChatGPT
Butterflies on wings of code,
Flutter, beauty grows.