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>
38 lines
1.2 KiB
Go
38 lines
1.2 KiB
Go
package diary
|
|
|
|
import "time"
|
|
|
|
// Entry is a single meal diary record.
|
|
type Entry struct {
|
|
ID string `json:"id"`
|
|
Date string `json:"date"` // YYYY-MM-DD
|
|
MealType string `json:"meal_type"`
|
|
Name string `json:"name"`
|
|
Portions float64 `json:"portions"`
|
|
Calories *float64 `json:"calories,omitempty"`
|
|
ProteinG *float64 `json:"protein_g,omitempty"`
|
|
FatG *float64 `json:"fat_g,omitempty"`
|
|
CarbsG *float64 `json:"carbs_g,omitempty"`
|
|
Source string `json:"source"`
|
|
DishID *string `json:"dish_id,omitempty"`
|
|
RecipeID *string `json:"recipe_id,omitempty"`
|
|
PortionG *float64 `json:"portion_g,omitempty"`
|
|
CreatedAt time.Time `json:"created_at"`
|
|
}
|
|
|
|
// CreateRequest is the body for POST /diary.
|
|
type CreateRequest struct {
|
|
Date string `json:"date"`
|
|
MealType string `json:"meal_type"`
|
|
Name string `json:"name"`
|
|
Portions float64 `json:"portions"`
|
|
Calories *float64 `json:"calories"`
|
|
ProteinG *float64 `json:"protein_g"`
|
|
FatG *float64 `json:"fat_g"`
|
|
CarbsG *float64 `json:"carbs_g"`
|
|
Source string `json:"source"`
|
|
DishID *string `json:"dish_id"`
|
|
RecipeID *string `json:"recipe_id"`
|
|
PortionG *float64 `json:"portion_g"`
|
|
}
|