The Nutritionix API is an online API which lets you access a massive database of nutrition information, covering both generic and branded food items. I came across it recently when looking for something else, and was promptly diverted from my original goal into trying it out.
While playing with it, it occurred to me that this could be the basis of a very neat little application to track calorie consumption. Ideally, it needed to work on a mobile device so that it would be at hand at meal-times, and be simple, interactive and easy to use. After a little thought, I had my requirements and design down, so I went ahead and built it.
For the user interface, I used jQuery Mobile and AngularJS (something I’ve been itching to play with for a while). On the server, I used Slim, a PHP micro-framework, to connect with the Nutritionix API. The application is deployed on IBM Bluemix, which is also responsible for providing a MySQL service instance for account and meal record storage.
Although I’ve used the PHP/MySQL combination on IBM Bluemix before, this application gave me an opportunity to try something new: email send-outs. If you’re developing locally, or on a system you have administrative privileges for, it’s easy enough to configure a mail server to handle outgoing email traffic, then use PHP’s mail() function to do the deed. On a PaaS service, this isn’t quite as easy…but Bluemix’s SendGrid service provides a viable solution if you’re willing to experiment a bit.
For the full story, read my IBM developerWorks article…and then, don’t forget to try the demo app.