How davguifer/code-cook works
Main System Components
• Frontend: The user interface built with Bootstrap, driven by Django templates (the HTML files in the recipes/templates/ and recommendation/templates/ directories).
• Backend (Django Application): The central component including:
• Core Django configuration (settings.py, urls.py, wsgi.py, asgi.py) for the overall application routing and server configuration.
• The "recipes" app – responsible for handling recipe data, including models, views, URL routing, and template rendering.
• The "recommendation" app – which contains logic for calculating and serving recommendations (with utility functions using Scikit-learn to compute TF-IDF and cosine similarity).
• Data Extraction Component: A script/process using Beautiful Soup and Requests that crawls BBC Good Food to extract recipe data.
• Search Indexing Module: Integration of Whoosh via the recipes/whoosh_config module that provides fast search and filtering functionalities.
• Database: Likely SQLite (although configurable in settings.py), which stores recipes, recommendation data, and user-related information.
Relationships and Data Flows
• User Interaction: A web browser sends HTTP requests that hit Django’s URL routing.
• Request Handling: Django views handle requests for recipe searches, loading data, and showing recommendations.
• Data Management: Views interact with Django models stored in the database (including both recipe and recommendation models).
• External Data Flow: A background process or a management command triggers the Beautiful Soup scraping module, which populates the database with fresh recipes.
• Search Feature: Once data is loaded, Whoosh indexes the recipe data. When a user performs a search (e.g., by title or cooking time), the application interacts with the Whoosh index to quickly fetch results.
• Recommendation Flow: When a recipe detail is viewed, the application relies on the precomputed TF-IDF based recommendation engine (using Scikit-learn) to display similar recipes.
Architectural Patterns and Technologies
• External integration points are important:
• How Beautiful Soup functions as a scraping tool.
• The Whoosh search index acting as a dedicated search engine.
• Scikit-learn’s role in the recommendation engine.
• That the system precomputes recommendations, which are then saved in the database for efficient lookups.