Tracking my coffee consumption with Redis, Sinatra and Cocoa
I’ve often joked about putting together an app to track my coffee consumption, such is my reputation for consuming the black goodness. Like a lot of my other personal projects, the idea had a prolonged gestation period and was finally born through a welcome spark of motivation.
Crafting fine web APIs
Thick client boogie
An unexpected resurgance in enthusiam for developing desktop apps combined with a fluency in cranking out webservices put me in a good position to put together a simple API and client.
I’m not a big user of mobile apps but I do spend the bulk of my waking hours sitting in front of a Mac so producing a client for OS X was the logical choice.
For the API I considered using something a bit more esoteric than my standard toolkit, but no matter what combination of technologies I investigated not much seems to come close to the power and flexibilty I find with Ruby and it’s frameworks for performing the bulk of tasks required by the web applications of today.
Areas of note
A valid API key must be sent in the request headers when sending a POST to the Sinatra app. Validity of the key is determined by checking set membership in Redis. A 4xx status code is returned if the key is missing or invalid.
The daily count is boosted with an atomic increment of a hash field.
The client is not much more than a GUI wrapper around some HTTP requests sent using AFNetworking. A previous native iOS client I developed used NSURLRequest directly and I found AFNetworking much simpler to use.
Get the code
You can keep up to date with my coffee consumption at coffee-tracker.herokuapp.com.