SatanshuMishra / CulinaryCache

An app to store culinary recipes.
1 stars 0 forks source link

[RFC] Proposal: A data encoding method for recipe instructions #3

Open VoxelMC opened 8 months ago

VoxelMC commented 8 months ago

Proposal

Introduction

This proposal outlines a method by which data for recipe instructions can be encoded within a database. It will utilize a stringified JSON object, which can be deserialized on the Astro server-side or the Tauri backend (preferred, translated into markdown and served via request on client-render(?)).

The Instructions Interface

This interface describes the general first level of a recipe Instructions object. This object describes the basic information, such as the name, author, date of writing, etc. It will also contain a property for variations and recipe-building instructions.

interface Instructions {
    name: string;
    author: string | Author;
    date: DateTime;
    // etc...
    sections: RecipeSection[];
}

The Instructions.sections Entry Array & RecipeSection Interface

This interface describes each section of a recipe, whether there is just one big section or a bunch of small ones. Each object encodes the name of the section, the ingredients and quantities, an index, and the itemized steps.

The index property is used to test for collisions, leading to two options: one variation or multiple variations at the same index. For example, when making Вареники, since only one dough type is used, and it is first in the order, it has index: 1. However, since different fillings exist, such as cherries or cottage cheese, they can all be placed at index: 2. The collision can be detected by mapping each index to an array and testing the length. If length > 1, then the user needs to choose between the items in the array.

interface RecipeSection {
    name: string;
    index: number;
    subtype?: string | SubtypeEnum;
    ingredients: {} satisfies Record<string, string>;
    steps: Array<string | RecipeSectionStep>;
}

interface RecipeSectionStep {
    instruction: string;
    photoSrc: string | URLResolvable;
}

Amendments may be made later, but let me know what you think!

SatanshuMishra commented 8 months ago

This is a very good proposal. I especially love the idea of using the index property to identify when multiple options are available.

Next step would be how the pieces of defining each of these levels would look like.

VoxelMC commented 8 months ago

This is a very good proposal. I especially love the idea of using the index property to identify when multiple options are available.

Next step would be how the pieces of defining each of these levels would look like.

Do you mean in the front-end?

SatanshuMishra commented 8 months ago

Yes. It is important we build a UI that makes inserting all the data above in a simple and straightforward manner. Would like to start workshopping designs with you soon.

VoxelMC commented 8 months ago

Yes. It is important we build a UI that makes inserting all the data above in a simple and straightforward manner. Would like to start workshopping designs with you soon.

Sounds good to me! As before, I was thinking a sort-of-Jupyter-Notebooks look and feel, where it is more like adding "cells" together?