FoodData.net is Live!

I’ve mentioned to some of you that I’ve been working on a web tool to look up nutritional information of foods.  The current sites that do this are not very simple, and none that I could find work well or at all on a mobile device.  Because I’ve found myself looking up nutritional information a lot recently, I thought I’d start up a small project to see if I could build something better.  And thus FoodData.net was born!

One of the reasons I’m releasing this right now, (as opposed to when I have all the fancy features below implemented,) is that I don’t foresee myself having a whole lot of time to work on this in the near future, as I’ve got a lot of other small projects I’m working on right now.  Additionally, I’m feeling that right now I have less of a need to be better at coding, and more of a need to be better at being a human.  In that light, any extra time I have will likely go toward the latter of those two.

Right now, the site supports looking up nutritional information for any food contained in the USDA nutrient database. I plan to keep adding features as time goes on, including:

  • Additional nutrients
  • Nutrient/calorie density measures
  • Ability to save recipes
  • Ability to add data for foods not included in the database

Although you can’t yet save a recipe on the site, each recipe has a unique URL, so you can always bookmark the site to come back to it, or send the link to others to share!

Technical Details:

For the devs, here are some implementation details, and some lessons learned:

This site uses Pyramid web framework with a combination of Mako and Moustache templates, and uses webassets to manage static assets.  SQLAlchemy is used for the ORM layer.

One of the goals of this project was to create a framework that could render UI both on the server and client, getting the advantages of both.  With server-side rendering, your pages are more search-engine-friendly and don’t require round trips back to the server for the initial page load.  With client-side rendering, you can be a lot more interactive and do incremental updates to the page without requiring a full reload. For this site, widgets are represented as moustache templates, with business logic written in a subset of Python on the server. For the client, the business logic code is translated into equivalent Javascript. It works, although there are a lot of limitations to translating code like this due to semantic differences between languages, (hence the reason business logic is restricted to a subset of Python only.)  I initially intended to write all UI business logic in Javascript and run it inside an embedded Javascript environment on the server, but it turns out the options for running Javascript in a Python environment are limited, even though PyV8 looked promising.  Lesson learned:  It helps to fully vet and experiment with tool/platform choices before diving in, even if they look good on the surface.

 

I hope some people might find it useful in its current state.  So head on over to fooddata.net, and tell me what you think!

5 replies on “FoodData.net is Live!”

Comments are closed.