Files
CookIT/docs/adr/0005-recipe-code-format.md
2026-10-28 22:55:09 +01:00

11 lines
1.6 KiB
Markdown
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# Recipe Codes: compressed JSON in Base45, one QR code per Recipe
Cooks who meet in person should be able to pass a Recipe from phone to phone without any connection, so a Recipe Code is a QR code that carries the Recipe itself rather than a link. Its text is `COOKIT1:` followed by the Recipe's Recipe Bundle JSON (without id, Photos, Favourite and Review Flag, plus the own units it uses), deflated and written in Base45 (RFC 9285). Base45 uses only the characters of QR's alphanumeric mode, which packs them densely enough that the text costs about as much space as the raw bytes would; this is the scheme the EU's vaccination certificates use. Measured on the original 214 Recipes, every one fits a single code (median QR version 23, largest 38), so there are no multi-part codes. Photos don't fit and travel only in a one-Recipe Recipe Bundle file instead.
## Consequences
- Only CookIt can read a Recipe Code; a plain camera app shows meaningless text. Readable plain text was considered and dropped: about a third of the Recipes wouldn't fit, and the structure would have to be guessed back.
- The number after `COOKIT` is the format version. A reader refuses higher numbers with "please update CookIt", and must keep reading every older version, because codes may live on as screenshots.
- The scanner uses ML Kit with its model bundled into the app (`mobile_scanner`'s default), not the Play-services download, so scanning works on a fresh install without internet. This adds about 3 MB to the APK.
- A received Recipe is always saved as a new Recipe with a new id, even if the same one exists – unlike a full Recipe Bundle import, which skips Recipes it already has.