Building a random Aeropress recipe generator for my search engine
Published on under the Blog Search Engine (Series) category.Toggle Memex mode

Back when I was working on my thermal printer project, I decided to build a random Aeropress recipe generator. The idea was that I would get a new Aeropress recipe in print every morning so that I could push myself when I was brewing. Truthfully, I didn't use the feature much because I was quite stubborn about using recipes I had refined through practice. However, I like the idea. Embracing randomness pushes one out of their comfort zone.
I decided to stop printing my Aeropress updates—and in fact the thermal printer project has been on hold while I have been building my plant monitor so I haven't used the printer in a while anyway—but I thought I could bring back the idea in another form: by launching the recipe generator on my search engine.
Updating the Aeropress recipe generator
I decided to copy the code I had written for my thermal printer Aeropress generator. This code already generated the following attributes:
- Dose
- Grind size (on an Encore, the grinder I was using at the time I wrote the program)
- Time
- How many times to stir the coffee
- When to stir the coffee (before or after the brew)
- How many filter papers I should use
The original program was written to only generate variables for standard Aeropress recipes (recipes where the Aeropress was not inverted) because that was my preference. Also, the original program gave grind size in the form of a number for the Encore. Reflecting on this, I realised I needed to make some changes to my original Aeropress recipe generator. I decided to add some code to decide if a recipe should use the inverted method or not. Here's what that code looks like:
inverted = random.choice([True, False])
The chance of getting an inverted method is one in two.
I also decided to update the grind size. Now the recipe generator gives grind size in the form of Comandante clicks. Here is the code that generates the number of clicks you should use:
# 1 in 7 chance I get a "really coarse" recipe with a coarse grind and a long brew time
type_is_really_coarse = random.randint(1, 7)
if type_is_really_coarse == 1:
grind_size = random.randint(25, 30)
time_in_seconds = random.randint(180, 300)
else:
grind_size = random.randint(18, 24)
time_in_seconds = random.randint(45, 150)
There is a one in seven chance you get a "really coarse" recipe. I have found coarser grinds and longer brew times can work well with the Aeropress (similar to what you may use in a Clever Dripper or a French press) so I wanted to add these as a feature. If a "really coarse" recipe is called for, the program will generate a number between 25 and 30 and a longer brew time. Otherwise, the grind size will be between 18 and 24 on a Comandante with a shorter brew time. (Remember, generally, longer brew times should use coarser grinds to prevent bitterness.)
I wrote some code on the front-end which says whether a grind is medium, medium-coarse, or coarse (the options I feel are best for most Aeropress recipes and thus the ones supported by the generator). I added this so that the grind size would be a bit easier for someone who does not have a Comandante to use the recipe generated. I understand a lot of people don't have a Comandante. I only got one about nine months after starting to brew coffee.
Here is an example "step 1" which states the grind size and the amount of coffee to use:
Weigh and grind 15 grams of coffee. Your coffee should be ground at 20 on a Comandante (medium-coarse).
As you can see, you get both a Comandante setting and a more general description of grind size (i.e. medium-coarse, like above).
I am not going to give away the logic for every part of the recipe generator: I want to surprise you with what recipes you might get.
Adding the generator to the search engine
The Aeropress recipe generator is triggered by typing "aeropress recipe generator" into the search engine. This will show you both the generator and search results below. This is because you might be looking for a blog post or a page on this site (like this one explaining how the generator works!) rather than the generator itself. The generator will always appear at the top of the "aeropress recipe generator" results page.
The generator translates the numbers that my Python program generates (i.e. grind size) into written text. I do this with a series of if statements that decides what text to show based on all of the attributes that I discussed earlier.
Above you can see a list of steps. The list includes all of the attributes you need to know to make an Aeropress coffee. If you want another recipe, you can refresh the page and another one will be generated for you. There are probably thousands of potential combinations based on the program I have written to generate recipes so you'll most likely see a unique result every time (although some recipes will be similar).
Wrapping up
This is my first foray into customised search features. I wonder how far this can go. I am in the process of adding a few more custom search features that show direct answers to certain queries (i.e. "what grinder do you use"). These will be available soon and may be discussed in a future blog post.
I wanted to build this custom feature because I already had the code ready and I think that random Aeropress recipes, if nothing else, are a good way to spice up your coffee brewing routine and encourage one to jump out of their comfort zone.
Type in "random aeropress recipe" into my blog search engine at search.jamesg.blog and give the recipe generated a go. If you tried it, let me know what you think. The recipe generated for you might just become your daily driver that you use every day.
Tagged in search engine.
Other posts in this series
Check out the other posts I have written as part of this series.
Responses
Comment on this post
Respond to this post by sending a Webmention.
Have a comment? Email me at readers@jamesg.blog.