Files
Django_TasksApp/docs/data/models.md
T

2.1 KiB

Data model map

Models are in each app's models.py; migrations, not this page, define the deployed schema. Most personal records reference Django's auth user. UUID API identifiers often coexist with integer database primary keys. Verify exact constraints and on_delete rules before writing data migrations.

App Models and purpose
planner Task, TaskOccurrence, TaskOccurrenceEvent, TaskWeatherShift manage scheduling; UserSettings, fasting and water models hold user settings and tracking; workout, pain, tooth, bowel and sleep models record health events.
food FoodProduct, FoodPortion, FoodLogEntry, FoodLogAttachment, FoodFavourite; KitchenInventoryItem, package/consumption and scanner models; CanonicalIngredient, nutrition import/source/review, suggestions and links; DietaryPreference, exception and audit; OAuth PAT, idempotency, housekeeping and Open Food Facts records.
recipes Recipe, ingredient, substitution, subrecipe and link models; selection and cook-later records; stock use lines and cooking runs.
groceries GroceryItem, GrocerySource, GroceryRecipeDemand connect shopping entries to recipe demand and inventory transfer.
home_assistant HomeAssistantConnection, HomeAssistantSyncRun, HomeAssistantItemMap store connection, sync history and stable mapping.
stress, dreams StressEntry, DreamEntry store private journal records.

Key cross-app relations: recipe ingredients can point to food products; recipe stock-use lines reference inventory consumption; grocery items can point to products and recipe demand; food diary entries snapshot nutrition so later recipe/product edits do not rewrite history. Recipe links are suggestions; subrecipes are composition. See features.

Validation lives in model clean() methods, forms, API helpers and services, not solely database constraints. Examples include positive quantities and serving counts, no self-link and uniqueness for recipe links, ownership checks, dietary revision checks, and idempotency on creation. Use the relevant service/API tests when changing these rules.