Files
meal-prep-vibecoded/models/models.go
2025-10-25 16:06:42 +02:00

66 lines
2.0 KiB
Go

package models
import "time"
// User represents a user account
type User struct {
ID int `json:"id"`
Email string `json:"email"`
PasswordHash string `json:"-"` // never expose in JSON
CreatedAt time.Time `json:"created_at"`
}
// Session represents a user session
type Session struct {
Token string `json:"token"`
UserID int `json:"user_id"`
ExpiresAt time.Time `json:"expires_at"`
CreatedAt time.Time `json:"created_at"`
}
// Ingredient represents a food ingredient
type Ingredient struct {
ID int `json:"id"`
UserID int `json:"user_id"`
Name string `json:"name"`
Unit string `json:"unit"` // e.g., "grams", "ml", "cups", "pieces", "tbsp"
}
// Meal represents a meal recipe
type Meal struct {
ID int `json:"id"`
UserID int `json:"user_id"`
Name string `json:"name"`
Description string `json:"description"`
MealType string `json:"meal_type"` // "breakfast", "lunch", "snack"
Instructions string `json:"instructions"`
PrepTime int `json:"prep_time"` // in minutes
ImageURL string `json:"image_url"`
}
// MealIngredient represents an ingredient in a meal with its quantity
type MealIngredient struct {
MealID int `json:"meal_id"`
IngredientID int `json:"ingredient_id"`
Quantity float64 `json:"quantity"`
// Joined fields
IngredientName string `json:"ingredient_name,omitempty"`
Unit string `json:"unit,omitempty"`
}
// WeekPlanEntry represents a meal planned for a specific date
type WeekPlanEntry struct {
ID int `json:"id"`
Date time.Time `json:"date"`
MealID int `json:"meal_id"`
MealName string `json:"meal_name,omitempty"`
MealType string `json:"meal_type,omitempty"` // "breakfast", "lunch", "snack"
}
// GroceryItem represents an aggregated ingredient for shopping
type GroceryItem struct {
IngredientName string `json:"ingredient_name"`
TotalQuantity float64 `json:"total_quantity"`
Unit string `json:"unit"`
}