Building BCBCBath: Automating a Cookbook Club Website
In 2022, Sahil and I started BCBCBath, a cookbook club in Bangalore, as a way to connect with fellow food lovers and explore diverse cuisines. Each month, members vote on a cookbook, cook a dish from it at home, and gather for a themed potluck. Here’s how I automated our website to make managing the club easier, including recent enhancements using AI for recipe extraction.
The Challenge
As our club grew, we needed a system that could:
- Track monthly potlucks and attendance
- Display cookbook information (including covers and descriptions)
- Display specific recipes prepared by members (a new challenge!)
- Archive our culinary journey
- Make updates easy for non-technical members
The Solution
I built an automated system using PHP that connects Google Sheets (where members log their dishes) with a dynamic website. Here’s how it works:
1. Data Management
Members use a Google Spreadsheet where:
- Each tab represents a different potluck
- Standard columns track cookbook details, date, and attendance
- Members log their chosen recipes and dietary information
- The familiar interface means no learning curve
2. Cookbook PDF Pre-processing
To handle recipe extraction efficiently, we added a preliminary step:
- Cookbook PDF files are stored locally in a dedicated folder.
- A separate PHP script is run whenever new cookbook files are added.
- This script utilizes a PDF parsing library to extract the full text from each document.
- The extracted text is saved into corresponding plain text files in another folder. This avoids repeatedly parsing large documents during regular data updates.
3. Data Processing Pipeline
The main PHP application:
- Connects to the Google Sheets API to get the list of potlucks (sheets).
- Checks which potlucks are new or haven’t been processed yet by tracking sheet identifiers.
- For new potlucks:
- Fetches the dish & attendance data from the relevant Google Sheet tab via CSV export.
- Parses and validates the information.
- Reads the pre-extracted full text from the corresponding plain text file generated in the pre-processing step.
- Calls the Google Gemini API (using standard PHP methods for the API call) for each dish, providing the recipe title and the full cookbook text. It asks the generative AI model to extract the specific recipe or return ‘NOT_FOUND’.
- Stores the extracted recipe content (or null if not found/error) along with other potluck data.
- Stores everything in a structured JSON data file for the website to use.
- Handles error cases gracefully during API calls and file reading using a logging utility.
4. Cookbook & Recipe Enhancement
To make the experience richer, the system:
- Uses the Google Books API to search for cookbook covers and descriptions.
- Generates Amazon purchase links (with an affiliate tag) when available.
- Caches cover images locally for performance.
- Falls back to placeholders when needed.
- Displays the extracted recipe content (obtained via the Gemini API) on the potluck detail page, toggleable via a “View Recipe” button.
5. Dynamic Website
The frontend:
- Displays potlucks in a responsive grid (using data loaded from the JSON file).
- Shows detailed information for each event, including the dish list and extracted recipes.
- Uses modern CSS for clean layouts.
- Works well on mobile devices.
Technical Architecture
- Data Layer
- Google Sheets as the primary database for sign-ups.
- Local storage for cookbook document files.
- Storage for pre-processed plain text files.
- A JSON file for processed & combined data storage.
- Local image cache for performance.
- Processing Layer (Backend PHP Scripts)
- Google Sheets API data fetching and parsing.
- PDF to text pre-processing (using a PDF parsing library).
- Google Books API for metadata retrieval.
- Google Gemini API recipe extraction.
- Data validation and cleaning.
- Error handling and logging.
- Presentation Layer (Frontend PHP & Templates)
- Simple PHP routing.
- PHP Templating for HTML generation.
- Responsive CSS.
Conclusion
By automating BCBCBath’s website and incorporating AI for recipe extraction, I’ve created a system that makes managing our cookbook club significantly easier while preserving our culinary journey in more detail. The combination of familiar tools (Google Sheets) with automated processing (PHP, APIs) lets us focus on what matters most: sharing great food and building community.