feat: core schema redesign — dishes, structured recipes, cuisines, tags (iteration 7)
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>
This commit is contained in:
19
client/lib/core/locale/cuisine_provider.dart
Normal file
19
client/lib/core/locale/cuisine_provider.dart
Normal file
@@ -0,0 +1,19 @@
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
|
||||
import '../api/cuisine_repository.dart';
|
||||
import '../../shared/models/cuisine.dart';
|
||||
import 'language_provider.dart';
|
||||
|
||||
/// Fetches and caches cuisines with localized names.
|
||||
/// Returns list of [Cuisine] objects.
|
||||
/// Re-fetches automatically when languageProvider changes.
|
||||
final cuisinesProvider = FutureProvider<List<Cuisine>>((ref) {
|
||||
ref.watch(languageProvider); // invalidate when language changes
|
||||
return ref.read(cuisineRepositoryProvider).fetchCuisines();
|
||||
});
|
||||
|
||||
/// Convenience provider that returns a slug → localized name map.
|
||||
final cuisineNamesProvider = FutureProvider<Map<String, String>>((ref) async {
|
||||
final cuisines = await ref.watch(cuisinesProvider.future);
|
||||
return {for (final c in cuisines) c.slug: c.name};
|
||||
});
|
||||
19
client/lib/core/locale/tag_provider.dart
Normal file
19
client/lib/core/locale/tag_provider.dart
Normal file
@@ -0,0 +1,19 @@
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
|
||||
import '../api/tag_repository.dart';
|
||||
import '../../shared/models/tag.dart';
|
||||
import 'language_provider.dart';
|
||||
|
||||
/// Fetches and caches tags with localized names.
|
||||
/// Returns list of [Tag] objects.
|
||||
/// Re-fetches automatically when languageProvider changes.
|
||||
final tagsProvider = FutureProvider<List<Tag>>((ref) {
|
||||
ref.watch(languageProvider); // invalidate when language changes
|
||||
return ref.read(tagRepositoryProvider).fetchTags();
|
||||
});
|
||||
|
||||
/// Convenience provider that returns a slug → localized name map.
|
||||
final tagNamesProvider = FutureProvider<Map<String, String>>((ref) async {
|
||||
final tags = await ref.watch(tagsProvider.future);
|
||||
return {for (final t in tags) t.slug: t.name};
|
||||
});
|
||||
Reference in New Issue
Block a user