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>
100 lines
3.4 KiB
Dart
100 lines
3.4 KiB
Dart
// GENERATED CODE - DO NOT MODIFY BY HAND
|
|
|
|
part of 'recipe.dart';
|
|
|
|
// **************************************************************************
|
|
// JsonSerializableGenerator
|
|
// **************************************************************************
|
|
|
|
Recipe _$RecipeFromJson(Map<String, dynamic> json) => Recipe(
|
|
title: json['title'] as String,
|
|
description: json['description'] as String,
|
|
cuisine: json['cuisine'] as String,
|
|
difficulty: json['difficulty'] as String,
|
|
prepTimeMin: (json['prep_time_min'] as num).toInt(),
|
|
cookTimeMin: (json['cook_time_min'] as num).toInt(),
|
|
servings: (json['servings'] as num).toInt(),
|
|
imageUrl: json['image_url'] as String? ?? '',
|
|
imageQuery: json['image_query'] as String? ?? '',
|
|
ingredients:
|
|
(json['ingredients'] as List<dynamic>?)
|
|
?.map((e) => RecipeIngredient.fromJson(e as Map<String, dynamic>))
|
|
.toList() ??
|
|
[],
|
|
steps:
|
|
(json['steps'] as List<dynamic>?)
|
|
?.map((e) => RecipeStep.fromJson(e as Map<String, dynamic>))
|
|
.toList() ??
|
|
[],
|
|
tags:
|
|
(json['tags'] as List<dynamic>?)?.map((e) => e as String).toList() ?? [],
|
|
nutrition: json['nutrition_per_serving'] == null
|
|
? null
|
|
: NutritionInfo.fromJson(
|
|
json['nutrition_per_serving'] as Map<String, dynamic>,
|
|
),
|
|
);
|
|
|
|
Map<String, dynamic> _$RecipeToJson(Recipe instance) => <String, dynamic>{
|
|
'title': instance.title,
|
|
'description': instance.description,
|
|
'cuisine': instance.cuisine,
|
|
'difficulty': instance.difficulty,
|
|
'prep_time_min': instance.prepTimeMin,
|
|
'cook_time_min': instance.cookTimeMin,
|
|
'servings': instance.servings,
|
|
'image_url': instance.imageUrl,
|
|
'image_query': instance.imageQuery,
|
|
'ingredients': instance.ingredients.map((e) => e.toJson()).toList(),
|
|
'steps': instance.steps.map((e) => e.toJson()).toList(),
|
|
'tags': instance.tags,
|
|
'nutrition_per_serving': instance.nutrition?.toJson(),
|
|
};
|
|
|
|
RecipeIngredient _$RecipeIngredientFromJson(Map<String, dynamic> json) =>
|
|
RecipeIngredient(
|
|
name: json['name'] as String,
|
|
amount: (json['amount'] as num).toDouble(),
|
|
unit: json['unit'] as String? ?? '',
|
|
unitCode: json['unit_code'] as String?,
|
|
);
|
|
|
|
Map<String, dynamic> _$RecipeIngredientToJson(RecipeIngredient instance) =>
|
|
<String, dynamic>{
|
|
'name': instance.name,
|
|
'amount': instance.amount,
|
|
'unit': instance.unit,
|
|
'unit_code': instance.unitCode,
|
|
};
|
|
|
|
RecipeStep _$RecipeStepFromJson(Map<String, dynamic> json) => RecipeStep(
|
|
number: (json['number'] as num).toInt(),
|
|
description: json['description'] as String,
|
|
timerSeconds: (json['timer_seconds'] as num?)?.toInt(),
|
|
);
|
|
|
|
Map<String, dynamic> _$RecipeStepToJson(RecipeStep instance) =>
|
|
<String, dynamic>{
|
|
'number': instance.number,
|
|
'description': instance.description,
|
|
'timer_seconds': instance.timerSeconds,
|
|
};
|
|
|
|
NutritionInfo _$NutritionInfoFromJson(Map<String, dynamic> json) =>
|
|
NutritionInfo(
|
|
calories: (json['calories'] as num).toDouble(),
|
|
proteinG: (json['protein_g'] as num).toDouble(),
|
|
fatG: (json['fat_g'] as num).toDouble(),
|
|
carbsG: (json['carbs_g'] as num).toDouble(),
|
|
approximate: json['approximate'] as bool? ?? true,
|
|
);
|
|
|
|
Map<String, dynamic> _$NutritionInfoToJson(NutritionInfo instance) =>
|
|
<String, dynamic>{
|
|
'calories': instance.calories,
|
|
'protein_g': instance.proteinG,
|
|
'fat_g': instance.fatG,
|
|
'carbs_g': instance.carbsG,
|
|
'approximate': instance.approximate,
|
|
};
|