Skip to content

Core Concepts and Data Model

Mike Christensen edited this page Aug 28, 2026 · 1 revision

Core concepts and data model

KitchenPC separates recipe-domain operations from storage and user interfaces.

Context and identity

IKPCContext is the engine boundary. It selects data loading, persistence, the current user, and available in-memory indexes. Initialize one context at application startup and reuse it.

AuthIdentity contains a user ID and alias. Database-backed menus, queues, ratings, and shopping lists are scoped through context.Identity.

var anonymous = AuthIdentity.Anonymous;
var user = new AuthIdentity(userId, "Ada");
IKPCContext userContext = dbContext.AsUserContext(user);

AsUserContext creates a lightweight identity-specific view; it does not rebuild indexes.

Lightweight references

Domain objects can identify records without loading them:

var recipe = Recipe.FromId(recipeId);
var ingredient = Ingredient.FromId(ingredientId);
var menu = Menu.FromId(menuId);

Use context.Recipes.Load(...).List() when fields are required. Fluent calls accept references so several IDs can be batched into one adapter operation.

Ingredient model

  • Ingredient is a normalized food, such as milk or banana.
  • IngredientForm describes a measurable form, such as whole, chopped, or melted.
  • Amount combines a numeric size with a Units value.
  • IngredientUsage binds ingredient, form, amount, preparation note, and optional recipe section.
  • IngredientAggregation is the normalized output of combining compatible usages.

Conversion depends on form metadata in the store. Weight, volume, and whole-unit expressions are not automatically interchangeable unless KitchenPC knows the required form ratios.

Recipe model

Recipe holds descriptive fields, time, yield, tags, method, image, rating data, and structured ingredient sections. RecipeBrief is a smaller search and queue representation. RecipeTags is a flag set covering meal, diet, nutrition, taste, and skill classifications.

The categorization subsystem can infer classifications from recipe text, ingredients, quantities, and ingredient metadata. Recipe search exposes these as filters.

Deferred fluent actions

Fluent objects collect an operation until a terminal method executes it:

  • reads: List() / ListAsync();
  • search: Results() / ResultsAsync();
  • mutations: Commit() and, where available, CommitAsync();
  • modeling: Generate() / Compile().

Persistence

StaticContext is a read-mostly snapshot playground. DBContext delegates persistence to IDBAdapter. The supplied DatabaseAdapter stores recipes, ratings, menus, queues, shopping lists, ingredient metadata, and NLP data in a relational schema.

The physical PostgreSQL ingredient catalog table is named shoppingingredients for compatibility with the production KitchenPC website. Public APIs use the simpler ingredient terminology.

Clone this wiki locally