Replaces the flat JSONB-based recipe schema with a normalized relational model:
Schema (migrations consolidated to 001_initial_schema + 002_seed_data):
- New: dishes, dish_translations, dish_tags — canonical dish catalog
- New: cuisines, tags, dish_categories with _translations tables + full seed data
- New: recipe_ingredients, recipe_steps with _translations (replaces JSONB blobs)
- New: user_saved_recipes thin bookmark (drops saved_recipes + saved_recipe_translations)
- New: product_ingredients M2M table
- recipes: now a cooking variant of a dish (dish_id FK, no title/JSONB columns)
- recipe_translations: repurposed to per-language notes only
- products: mapping_id → primary_ingredient_id
- menu_items: recipe_id FK → recipes; adds dish_id
- meal_diary: adds dish_id, recipe_id → recipes, portion_g
Backend (Go):
- New packages: internal/cuisine, internal/tag, internal/dish (registry + handler + repo)
- New GET /cuisines, GET /tags (public), GET /dishes, GET /dishes/{id}, GET /recipes/{id}
- recipe, savedrecipe, menu, diary, product, ingredient packages updated for new schema
Flutter:
- New models: Cuisine, Tag; new providers: cuisineNamesProvider, tagNamesProvider
- recipe.dart: RecipeIngredient gains unit_code + effectiveUnit getter
- saved_recipe.dart: thin model, manual fromJson, computed nutrition getter
- diary_entry.dart: adds dishId, recipeId, portionG
- recipe_detail_screen.dart: localized cuisine/tag names via providers
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1.7 KiB
Project Rules
Language
- All code comments must be written in English.
- All git commit messages must be written in English.
Localisation
Rule: Every table that stores human-readable text must have a companion {table}_translations
table. The base table always contains the English canonical text (used as fallback).
Translations live only in _translations tables — never as extra columns (name_ru, title_de).
SQL pattern
-- Base table — English canonical text always present
CREATE TABLE cuisines (
slug VARCHAR(50) PRIMARY KEY,
name TEXT NOT NULL,
sort_order SMALLINT NOT NULL DEFAULT 0
);
-- Translation companion
CREATE TABLE cuisine_translations (
cuisine_slug VARCHAR(50) REFERENCES cuisines(slug) ON DELETE CASCADE,
lang VARCHAR(10) NOT NULL,
name TEXT NOT NULL,
PRIMARY KEY (cuisine_slug, lang)
);
Query pattern
SELECT COALESCE(ct.name, c.name) AS name
FROM cuisines c
LEFT JOIN cuisine_translations ct ON ct.cuisine_slug = c.slug AND ct.lang = $lang
Already compliant tables
units + unit_translations, ingredient_categories + ingredient_category_translations,
ingredients + ingredient_translations + ingredient_aliases,
recipes + recipe_translations, cuisines + cuisine_translations,
tags + tag_translations, dish_categories + dish_category_translations,
dishes + dish_translations, recipe_ingredients + recipe_ingredient_translations,
recipe_steps + recipe_step_translations.
Rule when adding new entities
When adding a new entity with text fields, always create a {table}_translations
companion table and use LEFT JOIN COALESCE in all read queries.