The shake your phone feature is available on both the mobile web version of the site as well as in the iOS app (for people who are logged in).
At a high level, here's what happens when you shake your phone:
These are the recipes that you see in the final results.
In this step, a couple of key parameters from your profile are used to construct a baseline query.
First, which group of recipes will be retrieved? Your profile can be configured to look at all recipes, your favorite recipes, or, if you have permission, your own recipes.
Next, from which meal types will we select? Your profile can be configured to return any of dinner, lunch, salad, appetizer, (etc).
Finally, your allergies are collected so any recipes with ingredients that have those allergies can be eliminated during scoring.
Once the base set of recipes has been retrieved, each recipe is scored against your profile.
E.g.: here's what happens if you've self-identified as vegan in your profile:
This works similarly for users who have self-identified as paleo, vegetarian, mediterranean, etc.
Once every recipe has been assigned a score, the recipes are sorted in descending order of score.
The result set is then culled down to the recipes with the top fifty scores.
These recipes are randomly shuffled and are presented as the final search results.