### KitchenOwl Backend Setup Source: https://github.com/tombursch/kitchenowl/blob/main/docs/docs/reference/contributing.md Steps to set up the KitchenOwl backend. This involves installing Python dependencies using 'uv sync', installing pre-commit hooks, optionally activating a virtual environment, initializing the recipe scraper's NLTK data, upgrading the SQLite database, and running the debug server. ```shell cd backend uv sync uv run pre-commit install source .venv/bin/activate uv run python -c "import nltk; nltk.download('averaged_perceptron_tagger_eng', download_dir='.venv/nltk_data')" uv run flask db upgrade uv run wsgi.py uv run manage.py ``` -------------------------------- ### Install Pre-commit Hooks Source: https://github.com/tombursch/kitchenowl/blob/main/backend/README.md Installs the pre-commit hooks for the project. These hooks automate code quality checks and formatting before commits are made. ```shell uv run pre-commit install ``` -------------------------------- ### Install KitchenOwl with Docker Compose Source: https://github.com/tombursch/kitchenowl/blob/main/docs/docs/self-hosting/index.md This snippet provides the docker-compose.yml configuration for a multi-service KitchenOwl setup. It defines separate services for the front-end and back-end, specifying images, restart policies, ports, environment variables, and volumes. Ensure you change the default JWT_SECRET_KEY. ```yaml version: "3" services: front: image: tombursch/kitchenowl-web:latest restart: unless-stopped # environment: # - BACK_URL=back:5000 # Change this if you rename the containers ports: - "80:80" depends_on: - back back: image: tombursch/kitchenowl-backend:latest restart: unless-stopped environment: - JWT_SECRET_KEY=PLEASE_CHANGE_ME volumes: - kitchenowl_data:/data volumes: kitchenowl_data: ``` -------------------------------- ### KitchenOwl Backend Command Override Example Source: https://github.com/tombursch/kitchenowl/blob/main/docs/docs/self-hosting/advanced.md Example of overriding the default start command for the KitchenOwl backend service, often used in Docker or similar environments to specify initialization parameters. ```yml back: # ... other configurations ... command: --ini wsgi.ini:web --gevent 2000 # default: 100 # ... other configurations ... ``` -------------------------------- ### KitchenOwl Website Setup Source: https://github.com/tombursch/kitchenowl/blob/main/docs/docs/reference/contributing.md Steps to set up the KitchenOwl website development environment. This requires installing Hugo and then running the Hugo server to preview the website locally. ```shell git clone cd hugo server ``` -------------------------------- ### KitchenOwl Docs Setup Source: https://github.com/tombursch/kitchenowl/blob/main/docs/docs/reference/contributing.md Instructions for setting up the documentation build environment. This involves creating and activating a Python virtual environment, installing dependencies from 'requirements.txt', and serving the documentation locally. ```shell cd ./docs python3 -m venv venv source venv/bin/activate pip3 install -r requirements.txt mkdocs serve ``` -------------------------------- ### Project Setup and Basic Configuration Source: https://github.com/tombursch/kitchenowl/blob/main/kitchenowl/linux/CMakeLists.txt Configures the minimum CMake version, project name, executable name, application ID, and installation path for libraries. ```cmake cmake_minimum_required(VERSION 3.10) project(runner LANGUAGES CXX) # The name of the executable created for the application. Change this to change # the on-disk name of your application. set(BINARY_NAME "kitchenowl") # The unique GTK application identifier for this application. See: # https://wiki.gnome.org/HowDoI/ChooseApplicationID set(APPLICATION_ID "com.tombursch.kitchenowl") # Explicitly opt in to modern CMake behaviors to avoid warnings with recent # versions of CMake. cmake_policy(SET CMP0063 NEW) # Load bundled libraries from the lib/ directory relative to the binary. set(CMAKE_INSTALL_RPATH "$ORIGIN/lib") ``` -------------------------------- ### KitchenOwl Frontend Setup Source: https://github.com/tombursch/kitchenowl/blob/main/docs/docs/reference/contributing.md Instructions for setting up the KitchenOwl frontend development environment. This includes installing Flutter, navigating to the project directory, fetching dependencies, creating an environment file, and running the application. ```shell cd ./kitchenowl flutter packages get touch .env flutter run ``` -------------------------------- ### Run Debug Server Source: https://github.com/tombursch/kitchenowl/blob/main/backend/README.md Starts the backend development server using the WSGI application. The server will be accessible at localhost:5000 for debugging purposes. ```shell uv run wsgi.py ``` -------------------------------- ### Installation Procedures Source: https://github.com/tombursch/kitchenowl/blob/main/kitchenowl/linux/CMakeLists.txt Configures the installation process to create a relocatable bundle, clean the build directory, and install the executable, data files, libraries, and native assets. ```cmake # === Installation === # By default, "installing" just makes a relocatable bundle in the build # directory. set(BUILD_BUNDLE_DIR "${PROJECT_BINARY_DIR}/bundle") if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT) set(CMAKE_INSTALL_PREFIX "${BUILD_BUNDLE_DIR}" CACHE PATH "..." FORCE) endif() # Start with a clean build bundle directory every time. install(CODE " file(REMOVE_RECURSE \"${BUILD_BUNDLE_DIR}/\") " COMPONENT Runtime) set(INSTALL_BUNDLE_DATA_DIR "${CMAKE_INSTALL_PREFIX}/data") set(INSTALL_BUNDLE_LIB_DIR "${CMAKE_INSTALL_PREFIX}/lib") install(TARGETS ${BINARY_NAME} RUNTIME DESTINATION "${CMAKE_INSTALL_PREFIX}" COMPONENT Runtime) install(FILES "${FLUTTER_ICU_DATA_FILE}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" COMPONENT Runtime) install(FILES "${FLUTTER_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" COMPONENT Runtime) foreach(bundled_library ${PLUGIN_BUNDLED_LIBRARIES}) install(FILES "${bundled_library}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" COMPONENT Runtime) endforeach(bundled_library) # Copy the native assets provided by the build.dart from all packages. set(NATIVE_ASSETS_DIR "${PROJECT_BUILD_DIR}native_assets/linux/") install(DIRECTORY "${NATIVE_ASSETS_DIR}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" COMPONENT Runtime) # Fully re-copy the assets directory on each build to avoid having stale files ``` -------------------------------- ### Install KitchenOwl with Docker Compose (All-in-one) Source: https://github.com/tombursch/kitchenowl/blob/main/docs/docs/self-hosting/index.md This snippet provides the docker-compose.yml for an all-in-one KitchenOwl deployment. It uses a single service with the 'tombursch/kitchenowl:latest' image, maps port 8080, sets the JWT secret key, and persists data using a volume. Remember to change the default JWT_SECRET_KEY. ```yaml version: "3" services: back: image: tombursch/kitchenowl:latest restart: unless-stopped ports: - "80:8080" environment: - JWT_SECRET_KEY=PLEASE_CHANGE_ME volumes: - kitchenowl_data:/data volumes: kitchenowl_data: ``` -------------------------------- ### Synchronize Dependencies with UV Source: https://github.com/tombursch/kitchenowl/blob/main/backend/README.md Installs or updates all project dependencies using the UV package manager. This command ensures that the development environment has all necessary libraries. ```shell uv sync ``` -------------------------------- ### Install KitchenOwl with Docker (All-in-one) Source: https://github.com/tombursch/kitchenowl/blob/main/docs/docs/self-hosting/index.md This snippet details the command to run a single, all-in-one KitchenOwl Docker container. It maps port 8080, sets a JWT secret key via an environment variable, and mounts a volume for data persistence. A volume named 'kitchenowl_data' must be created beforehand. ```shell docker volume create kitchenowl_data docker run -d -p 8080:8080 -e "JWT_SECRET_KEY=PLEASE_CHANGE_ME" -v kitchenowl_data:/data tombursch/kitchenowl:latest ``` -------------------------------- ### Update KitchenOwl via Docker Compose Source: https://github.com/tombursch/kitchenowl/blob/main/docs/docs/self-hosting/index.md This command sequence is used to update a KitchenOwl installation managed by Docker Compose. It first pulls the latest images for all services defined in the compose file and then restarts the containers with the updated images. ```shell docker compose pull docker compose up -d ``` -------------------------------- ### Install Flutter Dependencies with Flutter Packages Get Source: https://github.com/tombursch/kitchenowl/blob/main/kitchenowl/README.md This command installs all the necessary dependencies for a Flutter project. It reads the `pubspec.yaml` file and downloads the packages listed. Ensure you are in the project's root directory before running. ```flutter flutter packages get ``` -------------------------------- ### Docker Compose for PostgreSQL Setup Source: https://github.com/tombursch/kitchenowl/blob/main/docs/docs/self-hosting/advanced.md Example docker-compose.yml file for setting up KitchenOwl with a PostgreSQL database. This file defines the services, networks, and volumes required for the application and its database. ```yaml version: "3.8" services: kitchenowl: image: tombursch/kitchenowl-backend ports: - "8080:8080" environment: DB_DRIVER: "postgresql" DB_HOST: "db" DB_PORT: "5432" DB_USER: "kitchenowl" DB_PASSWORD: "kitchenowl" DB_NAME: "kitchenowl" FRONT_URL: "http://localhost:3000" depends_on: - db db: image: postgres:14 ports: - "5432:5432" environment: POSTGRES_USER: "kitchenowl" POSTGRES_PASSWORD: "kitchenowl" POSTGRES_DB: "kitchenowl" volumes: - postgres_data:/var/lib/postgresql/data volumes: postgres_data: ``` -------------------------------- ### Installation Rules Source: https://github.com/tombursch/kitchenowl/blob/main/kitchenowl/windows/CMakeLists.txt Defines the installation process for the KitchenOwl application. It specifies how the executable, Flutter assets, libraries, bundled plugins, native assets, and AOT libraries are copied to the installation directory, ensuring the application can run correctly. ```cmake # === Installation === set(BUILD_BUNDLE_DIR "$") set(CMAKE_VS_INCLUDE_INSTALL_TO_DEFAULT_BUILD 1) if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT) set(CMAKE_INSTALL_PREFIX "${BUILD_BUNDLE_DIR}" CACHE PATH "..." FORCE) endif() set(INSTALL_BUNDLE_DATA_DIR "${CMAKE_INSTALL_PREFIX}/data") set(INSTALL_BUNDLE_LIB_DIR "${CMAKE_INSTALL_PREFIX}") install(TARGETS ${BINARY_NAME} RUNTIME DESTINATION "${CMAKE_INSTALL_PREFIX}" COMPONENT Runtime) install(FILES "${FLUTTER_ICU_DATA_FILE}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" COMPONENT Runtime) install(FILES "${FLUTTER_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" COMPONENT Runtime) if(PLUGIN_BUNDLED_LIBRARIES) install(FILES "${PLUGIN_BUNDLED_LIBRARIES}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" COMPONENT Runtime) endif() set(NATIVE_ASSETS_DIR "${PROJECT_BUILD_DIR}native_assets/windows/") install(DIRECTORY "${NATIVE_ASSETS_DIR}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" COMPONENT Runtime) set(FLUTTER_ASSET_DIR_NAME "flutter_assets") install(CODE " file(REMOVE_RECURSE \"${INSTALL_BUNDLE_DATA_DIR}/${FLUTTER_ASSET_DIR_NAME}\") " COMPONENT Runtime) install(DIRECTORY "${PROJECT_BUILD_DIR}/${FLUTTER_ASSET_DIR_NAME}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" COMPONENT Runtime) install(FILES "${AOT_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" CONFIGURATIONS Profile;Release COMPONENT Runtime) ``` -------------------------------- ### All-in-One Docker Image Source: https://github.com/tombursch/kitchenowl/blob/main/docs/docs/self-hosting/migration.md Starting from v0.5.0, the frontend is no longer a separate requirement. The `tombursch/kitchenowl:latest` image now includes both the web application and backend, simplifying the setup. ```dockerfile docker pull tombursch/kitchenowl:latest ``` -------------------------------- ### Initialize NLTK Data for Recipe Scraper Source: https://github.com/tombursch/kitchenowl/blob/main/backend/README.md Downloads and initializes the 'averaged_perceptron_tagger_eng' dataset from NLTK, which is required by the recipe scraper. It specifies the download directory within the virtual environment. ```shell uv run python -c "import nltk; nltk.download('averaged_perceptron_tagger_eng', download_dir='.venv/nltk_data')" ``` -------------------------------- ### Manage Backend with Script Source: https://github.com/tombursch/kitchenowl/blob/main/backend/README.md Executes the manage.py script, which provides utility functions for backend management, such as adding users or performing administrative tasks. ```shell uv run manage.py ``` -------------------------------- ### Install fastlane and Xcode Command Line Tools Source: https://github.com/tombursch/kitchenowl/blob/main/kitchenowl/ios/fastlane/README.md Installs necessary Xcode command line tools and the fastlane toolchain using gem or Homebrew. Ensure you have the latest Xcode command line tools before proceeding with fastlane installation. ```shell xcode-select --install [sudo] gem install fastlane -NV brew install fastlane ``` -------------------------------- ### Activate Python Virtual Environment Source: https://github.com/tombursch/kitchenowl/blob/main/backend/README.md Activates the project's Python virtual environment. This allows commands to be run without the `uv run` prefix, simplifying workflow. ```shell source .venv/bin/activate ``` -------------------------------- ### Navigate to Backend Directory Source: https://github.com/tombursch/kitchenowl/blob/main/backend/README.md Changes the current working directory to the backend folder of the project. This is a prerequisite for executing most backend-related commands. ```shell cd backend ``` -------------------------------- ### KitchenOwl Docker Compose Multiservice Setup Source: https://github.com/tombursch/kitchenowl/blob/main/docs/docs/self-hosting/advanced.md A Docker Compose configuration file demonstrating a multiservice setup for KitchenOwl, separating the frontend and backend into distinct Docker containers. ```yml version: "3" services: front: image: tombursch/kitchenowl-web:latest restart: unless-stopped ports: - "80:80" depends_on: - back back: image: tombursch/kitchenowl-backend:latest restart: unless-stopped environment: - JWT_SECRET_KEY=PLEASE_CHANGE_ME volumes: - kitchenowl_data:/data volumes: kitchenowl_data: ``` -------------------------------- ### VS Code Debug Configuration - Frontend Source: https://github.com/tombursch/kitchenowl/blob/main/docs/docs/reference/contributing.md Example VS Code launch.json configuration for debugging the KitchenOwl Flutter frontend. It includes configurations for standard launch and profile mode. ```json { "configurations": [ { "name": "kitchenowl", "request": "launch", "type": "dart" }, { "name": "kitchenowl (profile mode)", "request": "launch", "type": "dart", "flutterMode": "profile" } ] } ``` -------------------------------- ### Project Setup and Build Configuration Source: https://github.com/tombursch/kitchenowl/blob/main/kitchenowl/windows/CMakeLists.txt Configures the CMake project, sets the binary name, defines build policies, and manages build type configurations (Debug, Profile, Release). It also sets Unicode definitions and standard compiler flags. ```cmake cmake_minimum_required(VERSION 3.14) project(kitchenowl LANGUAGES CXX) set(BINARY_NAME "kitchenowl") cmake_policy(VERSION 3.14...3.25) get_property(IS_MULTICONFIG GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG) if(IS_MULTICONFIG) set(CMAKE_CONFIGURATION_TYPES "Debug;Profile;Release" CACHE STRING "" FORCE) else() if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES) set(CMAKE_BUILD_TYPE "Debug" CACHE STRING "Flutter build mode" FORCE) set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Debug" "Profile" "Release") endif() endif() set(CMAKE_EXE_LINKER_FLAGS_PROFILE "${CMAKE_EXE_LINKER_FLAGS_RELEASE}") set(CMAKE_SHARED_LINKER_FLAGS_PROFILE "${CMAKE_SHARED_LINKER_FLAGS_RELEASE}") set(CMAKE_C_FLAGS_PROFILE "${CMAKE_C_FLAGS_RELEASE}") set(CMAKE_CXX_FLAGS_PROFILE "${CMAKE_CXX_FLAGS_RELEASE}") add_definitions(-DUNICODE -D_UNICODE) ``` -------------------------------- ### Install Xcode Command Line Tools Source: https://github.com/tombursch/kitchenowl/blob/main/kitchenowl/android/fastlane/README.md Installs the necessary command line tools for Xcode development. This is a prerequisite for using fastlane for iOS and macOS development. ```shell xcode-select --install ``` -------------------------------- ### Install Flutter Assets and AOT Library with CMake Source: https://github.com/tombursch/kitchenowl/blob/main/kitchenowl/linux/CMakeLists.txt This CMake script handles the installation of Flutter assets and the Ahead-Of-Time (AOT) compiled library. It ensures that previous asset directories are cleaned up before installing the new ones and conditionally installs the AOT library based on the build type. ```cmake set(FLUTTER_ASSET_DIR_NAME "flutter_assets") install( CODE " file(REMOVE_RECURSE \"${INSTALL_BUNDLE_DATA_DIR}/${FLUTTER_ASSET_DIR_NAME}\") " COMPONENT Runtime ) install(DIRECTORY "${PROJECT_BUILD_DIR}/${FLUTTER_ASSET_DIR_NAME}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" COMPONENT Runtime ) # Install the AOT library on non-Debug builds only. if(NOT CMAKE_BUILD_TYPE MATCHES "Debug") install(FILES "${AOT_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" COMPONENT Runtime ) endif() ``` -------------------------------- ### Upgrade SQLite Database Source: https://github.com/tombursch/kitchenowl/blob/main/backend/README.md Initializes or upgrades the project's SQLite database using Flask's database migration tools. This command ensures the database schema is up-to-date. ```shell uv run flask db upgrade ``` -------------------------------- ### VS Code Debug Configuration - Backend Source: https://github.com/tombursch/kitchenowl/blob/main/docs/docs/reference/contributing.md Example VS Code launch.json configuration for debugging the KitchenOwl Python backend using debugpy. It specifies the program to run (wsgi.py), enables Jinja and gevent debugging, and includes an option to expose the backend to the network. ```json { "configurations": [ { "name": "Python Debugger: KitchenOwl", "type": "debugpy", "request": "launch", "program": "wsgi.py", "jinja": true, "justMyCode": true, "gevent": true, "args": [ "--host=0.0.0.0" ] } ] } ``` -------------------------------- ### Cross-Building Setup Source: https://github.com/tombursch/kitchenowl/blob/main/kitchenowl/linux/CMakeLists.txt Configures CMake for cross-building environments by setting the sysroot and search paths based on the FLUTTER_TARGET_PLATFORM_SYSROOT variable. ```cmake if(FLUTTER_TARGET_PLATFORM_SYSROOT) set(CMAKE_SYSROOT ${FLUTTER_TARGET_PLATFORM_SYSROOT}) set(CMAKE_FIND_ROOT_PATH ${CMAKE_SYSROOT}) set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY) set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) endif() ``` -------------------------------- ### KitchenOwl Social Login Environment Variables Setup Source: https://github.com/tombursch/kitchenowl/blob/main/docs/docs/self-hosting/oidc.md Sets up environment variables for integrating social logins with Apple and Google providers in KitchenOwl. This includes specific client IDs and secrets for each service. ```yaml back: environment: - [...] - FRONT_URL= # front_url is required when using oidc - APPLE_CLIENT_ID= - APPLE_CLIENT_SECRET= - GOOGLE_CLIENT_ID= - GOOGLE_CLIENT_SECRET= ``` -------------------------------- ### Example Conventional Commit Messages Source: https://github.com/tombursch/kitchenowl/blob/main/docs/docs/reference/contributing.md Examples of Git commit messages formatted according to the Conventional Commits specification. This format helps in standardizing commit history and enabling automated changelog generation. ```git chore: update gqlgen dependency to v2.6.0 docs(README): add new contributing section fix: remove debug log statements ``` -------------------------------- ### Backend-Only Docker Image Source: https://github.com/tombursch/kitchenowl/blob/main/docs/docs/self-hosting/migration.md For users preferring a split setup, a dedicated backend Docker image is available. This image is designed to run the backend service independently. ```dockerfile docker pull tombursch/kitchenowl-backend:latest ``` -------------------------------- ### KitchenOwl OIDC Environment Variables Setup Source: https://github.com/tombursch/kitchenowl/blob/main/docs/docs/self-hosting/oidc.md Configures KitchenOwl to use OpenID Connect for authentication. Requires setting the front-end URL, issuer URL, client ID, and client secret for the OIDC provider. ```yaml back: environment: - [...] - FRONT_URL= # front_url is required when using oidc - OIDC_ISSUER= # e.g https://accounts.google.com - OIDC_CLIENT_ID= - OIDC_CLIENT_SECRET= ``` -------------------------------- ### Create Git Branch Source: https://github.com/tombursch/kitchenowl/blob/main/docs/docs/reference/contributing.md Guides users on creating a new Git branch for contributions using a specific naming convention. The format '/' is recommended, aligning with conventional commit types. ```bash git checkout -b '/' ``` -------------------------------- ### CMake: Flutter Library and Dependencies Setup Source: https://github.com/tombursch/kitchenowl/blob/main/kitchenowl/linux/flutter/CMakeLists.txt Configures the Flutter Linux library and its associated header files. It finds necessary packages (PkgConfig, GTK, GLIB, GIO), sets library paths, and defines an INTERFACE library 'flutter' with include directories and link libraries. ```CMake cmake_minimum_required(VERSION 3.10) set(EPHEMERAL_DIR "${CMAKE_CURRENT_SOURCE_DIR}/ephemeral") # Configuration provided via flutter tool. include(${EPHEMERAL_DIR}/generated_config.cmake) # Serves the same purpose as list(TRANSFORM ... PREPEND ...), # which isn't available in 3.10. function(list_prepend LIST_NAME PREFIX) set(NEW_LIST "") foreach(element ${${LIST_NAME}}) list(APPEND NEW_LIST "${PREFIX}${element}") endforeach(element) set(${LIST_NAME} "${NEW_LIST}" PARENT_SCOPE) endfunction() # === Flutter Library === # System-level dependencies. find_package(PkgConfig REQUIRED) pkg_check_modules(GTK REQUIRED IMPORTED_TARGET gtk+-3.0) pkg_check_modules(GLIB REQUIRED IMPORTED_TARGET glib-2.0) pkg_check_modules(GIO REQUIRED IMPORTED_TARGET gio-2.0) set(FLUTTER_LIBRARY "${EPHEMERAL_DIR}/libflutter_linux_gtk.so") # Published to parent scope for install step. set(FLUTTER_LIBRARY ${FLUTTER_LIBRARY} PARENT_SCOPE) set(FLUTTER_ICU_DATA_FILE "${EPHEMERAL_DIR}/icudtl.dat" PARENT_SCOPE) set(PROJECT_BUILD_DIR "${PROJECT_DIR}/build/" PARENT_SCOPE) set(AOT_LIBRARY "${PROJECT_DIR}/build/lib/libapp.so" PARENT_SCOPE) list(APPEND FLUTTER_LIBRARY_HEADERS "fl_basic_message_channel.h" "fl_binary_codec.h" "fl_binary_messenger.h" "fl_dart_project.h" "fl_engine.h" "fl_json_message_codec.h" "fl_json_method_codec.h" "fl_message_codec.h" "fl_method_call.h" "fl_method_channel.h" "fl_method_codec.h" "fl_method_response.h" "fl_plugin_registrar.h" "fl_plugin_registry.h" "fl_standard_message_codec.h" "fl_standard_method_codec.h" "fl_string_codec.h" "fl_value.h" "fl_view.h" "flutter_linux.h" ) list_prepend(FLUTTER_LIBRARY_HEADERS "${EPHEMERAL_DIR}/flutter_linux/") add_library(flutter INTERFACE) target_include_directories(flutter INTERFACE "${EPHEMERAL_DIR}" ) target_link_libraries(flutter INTERFACE "${FLUTTER_LIBRARY}") target_link_libraries(flutter INTERFACE PkgConfig::GTK PkgConfig::GLIB PkgConfig::GIO ) add_dependencies(flutter flutter_assemble) ``` -------------------------------- ### Jinja2 Template Inheritance and Block Source: https://github.com/tombursch/kitchenowl/blob/main/docs/overrides/main.html This snippet demonstrates extending a base HTML template using Jinja2's `extends` directive. It also shows how to define a block named 'outdated' to override or add content from the parent template, including dynamic URL generation. ```Jinja2 {% extends "base.html" %} {% block outdated %} You're not viewing the latest stable version. [**Click here to go to latest.**]({{ '../' ~ base_url }}) {% endblock %} ``` -------------------------------- ### HAProxy Reverse Proxy Configuration Source: https://github.com/tombursch/kitchenowl/blob/main/docs/docs/self-hosting/reverse-proxy.md Configuration for HAProxy to act as a reverse proxy for KitchenOwl. Assumes HAProxy is part of the KitchenOwl docker compose stack and uses multiservice setup. It defines frontend and backend services for HTTP and HTTPS traffic, including SSL termination and redirection. ```haproxy global log stdout local0 defaults mode http log global option httplog option forwardfor if-none retries 3 timeout http-request 10s timeout queue 1m timeout connect 10s timeout client 1m timeout server 1m timeout http-keep-alive 10s timeout check 10s default-server init-addr last,libc,none resolvers docker parse-resolv-conf #----------------------- # http #----------------------- frontend efeu-http bind :::80 v4v6 bind :::443 v4v6 ssl crt /etc/letsencrypt/live/domain/domain.pem redirect scheme https if !{ ssl_fc } # hsts max-age is mandatory # 16000000 seconds is a bit more than 6 months http-response set-header Strict-Transport-Security "max-age=16000000; includeSubDomains; preload;" default_backend kitchenowl backend kitchenowl server kitchenowl front:80 resolvers docker ``` -------------------------------- ### Traefik v2 Reverse Proxy and Security Middleware Configuration Source: https://github.com/tombursch/kitchenowl/blob/main/docs/docs/self-hosting/reverse-proxy.md Docker Compose configuration for Traefik v2 as a reverse proxy for KitchenOwl, including routing rules, entrypoints, and security middleware setup. This configuration enables Traefik to manage traffic, SSL, and apply security headers via custom middlewares. ```docker-compose version: "3" services: front: image: tombursch/kitchenowl-web:latest networks: - default - web restart: unless-stopped depends_on: - back labels: - "traefik.enable=true" - "traefik.docker.network=web" - "traefik.http.routers.kitchenowl.rule=Host(`your.domain.here`)" - "traefik.http.routers.kitchenowl.entrypoints=websecure" - "traefik.http.routers.kitchenowl.middlewares=security@docker" # Use to apply security middlewares back: image: tombursch/kitchenowl:latest networks: - default restart: unless-stopped environment: - FRONT_URL=https://your.domain.here - JWT_SECRET_KEY=PLEASE_CHANGE_ME volumes: - kitchenowl_data:/data networks: web: external: true volumes: kitchenowl_data: ``` ```docker-compose labels: - "traefik.http.middlewares.security.headers.addvaryheader=true" - "traefik.http.middlewares.security.headers.sslredirect=true" - "traefik.http.middlewares.security.headers.browserxssfilter=true" - "traefik.http.middlewares.security.headers.contenttypenosniff=true" - "traefik.http.middlewares.security.headers.forcestsheader=true" - "traefik.http.middlewares.security.headers.stsincludesubdomains=true" - "traefik.http.middlewares.security.headers.stspreload=true" - "traefik.http.middlewares.security.headers.stsseconds=63072000" - "traefik.http.middlewares.security.headers.customframeoptionsvalue=SAMEORIGIN" - "traefik.http.middlewares.security.headers.referrerpolicy=same-origin" ``` -------------------------------- ### Apache Reverse Proxy Configuration Source: https://github.com/tombursch/kitchenowl/blob/main/docs/docs/self-hosting/reverse-proxy.md Apache configuration for acting as a reverse proxy for KitchenOwl. This setup assumes Apache is running on the host, Certbot is used for SSL, and the KitchenOwl Docker containers are accessible on a specific port (e.g., 8080). It includes HTTP to HTTPS redirection and proxy directives. ```apache ServerName kitchenowl.example.org ServerAdmin webmaster@example.org ErrorLog ${APACHE_LOG_DIR}/kitchenowl_error.log CustomLog ${APACHE_LOG_DIR}/kitchenowl_access.log combined Redirect permanent / https://kitchenowl.example.org ServerName kitchenowl.example.org ServerAdmin webmaster@example.org Header always set Strict-Transport-Security "max-age=15552000; includeSubDomains; preload" ErrorLog ${APACHE_LOG_DIR}/kitchenowl_error.log CustomLog ${APACHE_LOG_DIR}/kitchenowl_access.log combined ProxyPass / http://localhost:8080/ ProxyPassReverse / http://localhost:8080/ SSLCertificateFile /etc/letsencrypt/live/kitchenowl.exaample.org/fullchain.pem SSLCertificateKeyFile /etc/letsencrypt/live/kitchenowl.exaample.org/privkey.pem Include /etc/letsencrypt/options-ssl-apache.conf ``` -------------------------------- ### Run fastlane iOS Actions Source: https://github.com/tombursch/kitchenowl/blob/main/kitchenowl/ios/fastlane/README.md Demonstrates how to execute common fastlane actions for iOS projects. These commands are used to automate tasks like pushing beta builds to TestFlight or running tests. ```shell fastlane ios beta fastlane ios test ``` -------------------------------- ### Flutter Application Build Configuration Source: https://github.com/tombursch/kitchenowl/blob/main/kitchenowl/windows/runner/CMakeLists.txt This CMakeLists.txt file sets up the build environment for a Flutter application on Windows. It defines the main executable target, includes necessary source files, applies standard build settings, and links against required libraries like flutter and dwmapi.lib. ```cmake cmake_minimum_required(VERSION 3.14) project(runner LANGUAGES CXX) # Define the application target. To change its name, change BINARY_NAME in the # top-level CMakeLists.txt, not the value here, or `flutter run` will no longer # work. # # Any new source files that you add to the application should be added here. add_executable(${BINARY_NAME} WIN32 "flutter_window.cpp" "main.cpp" "utils.cpp" "win32_window.cpp" "${FLUTTER_MANAGED_DIR}/generated_plugin_registrant.cc" "Runner.rc" "runner.exe.manifest" ) # Apply the standard set of build settings. This can be removed for applications # that need different build settings. apply_standard_settings(${BINARY_NAME}) # Add preprocessor definitions for the build version. target_compile_definitions(${BINARY_NAME} PRIVATE "FLUTTER_VERSION=\"${FLUTTER_VERSION}\"") target_compile_definitions(${BINARY_NAME} PRIVATE "FLUTTER_VERSION_MAJOR=${FLUTTER_VERSION_MAJOR}") target_compile_definitions(${BINARY_NAME} PRIVATE "FLUTTER_VERSION_MINOR=${FLUTTER_VERSION_MINOR}") target_compile_definitions(${BINARY_NAME} PRIVATE "FLUTTER_VERSION_PATCH=${FLUTTER_VERSION_PATCH}") target_compile_definitions(${BINARY_NAME} PRIVATE "FLUTTER_VERSION_BUILD=${FLUTTER_VERSION_BUILD}") # Disable Windows macros that collide with C++ standard library functions. target_compile_definitions(${BINARY_NAME} PRIVATE "NOMINMAX") # Add dependency libraries and include directories. Add any application-specific # dependencies here. target_link_libraries(${BINARY_NAME} PRIVATE flutter flutter_wrapper_app) target_link_libraries(${BINARY_NAME} PRIVATE "dwmapi.lib") target_include_directories(${BINARY_NAME} PRIVATE "${CMAKE_SOURCE_DIR}") # Run the Flutter tool portions of the build. This must not be removed. add_dependencies(${BINARY_NAME} flutter_assemble) ``` -------------------------------- ### Submit Android Beta Build Source: https://github.com/tombursch/kitchenowl/blob/main/kitchenowl/android/fastlane/README.md Submits a new beta build to Google Play using the fastlane tool. This is used for distributing builds to a selected group of testers. ```shell [bundle exec] fastlane android beta ``` -------------------------------- ### Dependency and Target Definition Source: https://github.com/tombursch/kitchenowl/blob/main/kitchenowl/linux/CMakeLists.txt Manages Flutter integration, system dependencies like GTK, defines the application executable, links libraries, and sets output properties. ```cmake # Flutter library and tool build rules. set(FLUTTER_MANAGED_DIR "${CMAKE_CURRENT_SOURCE_DIR}/flutter") add_subdirectory(${FLUTTER_MANAGED_DIR}) # System-level dependencies. find_package(PkgConfig REQUIRED) pkg_check_modules(GTK REQUIRED IMPORTED_TARGET gtk+-3.0) add_definitions(-DAPPLICATION_ID="${APPLICATION_ID}") # Define the application target. To change its name, change BINARY_NAME above, # not the value here, or `flutter run` will no longer work. # # Any new source files that you add to the application should be added here. add_executable(${BINARY_NAME} "main.cc" "my_application.cc" "${FLUTTER_MANAGED_DIR}/generated_plugin_registrant.cc" ) # Apply the standard set of build settings. This can be removed for applications # that need different build settings. apply_standard_settings(${BINARY_NAME}) # Add dependency libraries. Add any application-specific dependencies here. target_link_libraries(${BINARY_NAME} PRIVATE flutter) target_link_libraries(${BINARY_NAME} PRIVATE PkgConfig::GTK) # Run the Flutter tool portions of the build. This must not be removed. add_dependencies(${BINARY_NAME} flutter_assemble) # Only the install-generated bundle's copy of the executable will launch # correctly, since the resources must in the right relative locations. To avoid # people trying to run the unbundled copy, put it in a subdirectory instead of # the default top-level location. set_target_properties(${BINARY_NAME} PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/intermediates_do_not_run" ) # Generated plugin build rules, which manage building the plugins and adding # them to the application. include(flutter/generated_plugins.cmake) ``` -------------------------------- ### Submit Android Production Build Source: https://github.com/tombursch/kitchenowl/blob/main/kitchenowl/android/fastlane/README.md Submits a new production build to Google Play using the fastlane tool. This deploys the application to all users on the Google Play Store. ```shell [bundle exec] fastlane android production ``` -------------------------------- ### OpenAI LLM Configuration Source: https://github.com/tombursch/kitchenowl/blob/main/docs/docs/self-hosting/ingredient_parsing.md Configure the system to use OpenAI's Large Language Models for ingredient detection. This requires setting specific environment variables related to the model name and API key. ```APIDOC OpenAI Configuration: Description: Use OpenAI models for ingredient parsing and translation. Environment Variables: - LLM_MODEL: The name of the OpenAI model to use (e.g., "gpt-3.5-turbo"). - OPENAI_API_KEY: Your OpenAI API key for authentication. ``` -------------------------------- ### KitchenOwl Frontend Environment Variables Source: https://github.com/tombursch/kitchenowl/blob/main/docs/docs/self-hosting/advanced.md Configuration options for the KitchenOwl frontend service. These variables primarily control how the frontend connects to the backend service. ```APIDOC BACK_URL: description: Allows to set a custom address for the backend. Needs to be an uWSGI protocol endpoint. Should correspond to the name or IP of the backend container and port 5000. default: "back:5000" BASE_HREF: description: Sets the subdirectory KitchenOwl is hosted at. Must begin and end with a slash '/'. default: "" ``` -------------------------------- ### Flutter Build Configuration with CMake Source: https://github.com/tombursch/kitchenowl/blob/main/kitchenowl/windows/flutter/CMakeLists.txt This CMake script defines build configurations for a Flutter application, including setting up directories, including generated configurations, defining library targets, and managing wrapper sources for plugins and the application runner. It integrates with the Flutter tool backend for assembly. ```cmake cmake_minimum_required(VERSION 3.14) set(EPHEMERAL_DIR "${CMAKE_CURRENT_SOURCE_DIR}/ephemeral") # Configuration provided via flutter tool. include(${EPHEMERAL_DIR}/generated_config.cmake) # TODO: Move the rest of this into files in ephemeral. See # https://github.com/flutter/flutter/issues/57146. set(WRAPPER_ROOT "${EPHEMERAL_DIR}/cpp_client_wrapper") # Set fallback configurations for older versions of the flutter tool. if (NOT DEFINED FLUTTER_TARGET_PLATFORM) set(FLUTTER_TARGET_PLATFORM "windows-x64") endif() # === Flutter Library === set(FLUTTER_LIBRARY "${EPHEMERAL_DIR}/flutter_windows.dll") # Published to parent scope for install step. set(FLUTTER_LIBRARY ${FLUTTER_LIBRARY} PARENT_SCOPE) set(FLUTTER_ICU_DATA_FILE "${EPHEMERAL_DIR}/icudtl.dat" PARENT_SCOPE) set(PROJECT_BUILD_DIR "${PROJECT_DIR}/build/" PARENT_SCOPE) set(AOT_LIBRARY "${PROJECT_DIR}/build/windows/app.so" PARENT_SCOPE) list(APPEND FLUTTER_LIBRARY_HEADERS "flutter_export.h" "flutter_windows.h" "flutter_messenger.h" "flutter_plugin_registrar.h" "flutter_texture_registrar.h" ) list(TRANSFORM FLUTTER_LIBRARY_HEADERS PREPEND "${EPHEMERAL_DIR}/") add_library(flutter INTERFACE) target_include_directories(flutter INTERFACE "${EPHEMERAL_DIR}" ) target_link_libraries(flutter INTERFACE "${FLUTTER_LIBRARY}.lib") add_dependencies(flutter flutter_assemble) # === Wrapper === list(APPEND CPP_WRAPPER_SOURCES_CORE "core_implementations.cc" "standard_codec.cc" ) list(TRANSFORM CPP_WRAPPER_SOURCES_CORE PREPEND "${WRAPPER_ROOT}/") list(APPEND CPP_WRAPPER_SOURCES_PLUGIN "plugin_registrar.cc" ) list(TRANSFORM CPP_WRAPPER_SOURCES_PLUGIN PREPEND "${WRAPPER_ROOT}/") list(APPEND CPP_WRAPPER_SOURCES_APP "flutter_engine.cc" "flutter_view_controller.cc" ) list(TRANSFORM CPP_WRAPPER_SOURCES_APP PREPEND "${WRAPPER_ROOT}/") # Wrapper sources needed for a plugin. add_library(flutter_wrapper_plugin STATIC ${CPP_WRAPPER_SOURCES_CORE} ${CPP_WRAPPER_SOURCES_PLUGIN} ) apply_standard_settings(flutter_wrapper_plugin) set_target_properties(flutter_wrapper_plugin PROPERTIES POSITION_INDEPENDENT_CODE ON) set_target_properties(flutter_wrapper_plugin PROPERTIES CXX_VISIBILITY_PRESET hidden) target_link_libraries(flutter_wrapper_plugin PUBLIC flutter) target_include_directories(flutter_wrapper_plugin PUBLIC "${WRAPPER_ROOT}/include" ) add_dependencies(flutter_wrapper_plugin flutter_assemble) # Wrapper sources needed for the runner. add_library(flutter_wrapper_app STATIC ${CPP_WRAPPER_SOURCES_CORE} ${CPP_WRAPPER_SOURCES_APP} ) apply_standard_settings(flutter_wrapper_app) target_link_libraries(flutter_wrapper_app PUBLIC flutter) target_include_directories(flutter_wrapper_app PUBLIC "${WRAPPER_ROOT}/include" ) add_dependencies(flutter_wrapper_app flutter_assemble) # === Flutter tool backend === # _phony_ is a non-existent file to force this command to run every time, # since currently there's no way to get a full input/output list from the # flutter tool. set(PHONY_OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/_phony_") set_source_files_properties("${PHONY_OUTPUT}" PROPERTIES SYMBOLIC TRUE) add_custom_command( OUTPUT ${FLUTTER_LIBRARY} ${FLUTTER_LIBRARY_HEADERS} ${CPP_WRAPPER_SOURCES_CORE} ${CPP_WRAPPER_SOURCES_PLUGIN} ${CPP_WRAPPER_SOURCES_APP} ${PHONY_OUTPUT} COMMAND ${CMAKE_COMMAND} -E env ${FLUTTER_TOOL_ENVIRONMENT} "${FLUTTER_ROOT}/packages/flutter_tools/bin/tool_backend.bat" ${FLUTTER_TARGET_PLATFORM} $ VERBATIM ) add_custom_target(flutter_assemble DEPENDS "${FLUTTER_LIBRARY}" ${FLUTTER_LIBRARY_HEADERS} ${CPP_WRAPPER_SOURCES_CORE} ${CPP_WRAPPER_SOURCES_PLUGIN} ${CPP_WRAPPER_SOURCES_APP} ) ``` -------------------------------- ### Caddy Reverse Proxy for KitchenOwl Source: https://github.com/tombursch/kitchenowl/blob/main/docs/docs/self-hosting/reverse-proxy.md Sets up Caddy as a reverse proxy for KitchenOwl, automatically managing SSL certificates and configuring various security and performance headers. ```caddyfile kitchenowl.example.org { reverse_proxy localhost:8080 # Set the address of your KitchenOwl frontend here encode gzip header { X-Frame-Options "SAMEORIGIN" X-XSS-Protection "1; mode=block" X-Content-Type-Options "nosniff" Strict-Transport-Security "max-age=31536000; includeSubDomains; preload" Referrer-Policy "strict-origin-when-cross-origin" } } ``` -------------------------------- ### Execute KitchenOwl Server Management Script Source: https://github.com/tombursch/kitchenowl/blob/main/docs/docs/reference/management.md Command to enter the backend container and run the KitchenOwl management script. This script provides an interactive menu for server administration tasks such as managing users, households, and running jobs. ```bash docker exec -it BACKEND_CONTAINER_NAME python manage.py ``` -------------------------------- ### OpenRouter LLM Configuration Source: https://github.com/tombursch/kitchenowl/blob/main/docs/docs/self-hosting/ingredient_parsing.md Configure the system to use OpenRouter for accessing various LLM providers. This requires setting environment variables for the model, API URL, and API key. ```APIDOC OpenRouter Configuration: Description: Use OpenRouter to access a variety of LLM models for ingredient detection. Environment Variables: - LLM_MODEL: The model name prefixed with "openrouter" (e.g., "openrouter/mistralai/mistral-large"). - LLM_API_URL: The base URL for the OpenRouter API (e.g., "https://openrouter.ai/api/v1"). - OPENROUTER_API_KEY: Your OpenRouter API key for authentication. ``` -------------------------------- ### Ollama LLM Configuration Source: https://github.com/tombursch/kitchenowl/blob/main/docs/docs/self-hosting/ingredient_parsing.md Configure the system to use Ollama for locally hosted LLM inference. This allows for on-premise model execution and requires specifying the model name and API endpoint. ```APIDOC Ollama Configuration: Description: Use Ollama for locally hosted LLM ingredient parsing. Falls back to NLP if the host is unreachable. Environment Variables: - LLM_MODEL: The model name prefixed with "ollama" (e.g., "ollama/llama3.1"). - LLM_API_URL: The URL of the Ollama server (e.g., "http://localhost:11434"). ``` -------------------------------- ### Standard Compilation Settings Function Source: https://github.com/tombursch/kitchenowl/blob/main/kitchenowl/linux/CMakeLists.txt Defines a reusable CMake function to apply standard compilation features, warnings, optimization levels, and preprocessor definitions to targets. ```cmake # Compilation settings that should be applied to most targets. # # Be cautious about adding new options here, as plugins use this function by # default. In most cases, you should add new options to specific targets instead # of modifying this function. function(APPLY_STANDARD_SETTINGS TARGET) target_compile_features(${TARGET} PUBLIC cxx_std_14) target_compile_options(${TARGET} PRIVATE -Wall -Werror) target_compile_options(${TARGET} PRIVATE "$<$>:-O3>") target_compile_definitions(${TARGET} PRIVATE "$<$>:NDEBUG>") endfunction() ``` -------------------------------- ### Standard Settings Function Source: https://github.com/tombursch/kitchenowl/blob/main/kitchenowl/windows/CMakeLists.txt A CMake function to apply common compilation features and options to targets. It sets the C++ standard to C++17 and applies specific compiler warnings and exception handling settings. ```cmake function(APPLY_STANDARD_SETTINGS TARGET) target_compile_features(${TARGET} PUBLIC cxx_std_17) target_compile_options(${TARGET} PRIVATE /W4 /WX /wd"4100") target_compile_options(${TARGET} PRIVATE /EHsc) target_compile_definitions(${TARGET} PRIVATE "_HAS_EXCEPTIONS=0") target_compile_definitions(${TARGET} PRIVATE "$:_DEBUG") endfunction() ``` -------------------------------- ### KitchenOwl Backend Environment Variables Source: https://github.com/tombursch/kitchenowl/blob/main/docs/docs/self-hosting/advanced.md Configuration options for the KitchenOwl backend service. These variables control various aspects of the backend's functionality, including authentication, LLM integration, and base URL settings. ```APIDOC APPLE_CLIENT_SECRET_FILE: description: Allows setting APPLE_CLIENT_SECRET from a file path, will override APPLE_CLIENT_SECRET. GOOGLE_CLIENT_ID: description: Google OAuth Client ID. GOOGLE_CLIENT_SECRET: description: Google OAuth Client Secret. GOOGLE_CLIENT_SECRET_FILE: description: Allows setting GOOGLE_CLIENT_SECRET from a file path, will override GOOGLE_CLIENT_SECRET. LLM_MODEL: description: Set a custom ingredient detection strategy for scraped recipes from the web. More at [Ingredient Parsing](./ingredient_parsing.md). LLM_API_URL: description: URL for the Language Model API. OPENAI_API_KEY/OPENROUTER_API_KEY/etc.: description: Depends on which provider you choose. See [LiteLLM docs](https://docs.litellm.ai/docs/providers). BASE_HREF: description: Sets the subdirectory KitchenOwl is hosted at. Must begin and end with a slash '/'. Only applicable to tombursch/kitchenowl. ``` -------------------------------- ### Flutter Integration and Subdirectories Source: https://github.com/tombursch/kitchenowl/blob/main/kitchenowl/windows/CMakeLists.txt Includes the Flutter managed directory and the runner subdirectory, essential for integrating Flutter into the native build. It also includes generated plugin build rules. ```cmake set(FLUTTER_MANAGED_DIR "${CMAKE_CURRENT_SOURCE_DIR}/flutter") add_subdirectory(${FLUTTER_MANAGED_DIR}) add_subdirectory("runner") include(flutter/generated_plugins.cmake) ```