- Rust 62.5%
- JavaScript 32.8%
- CSS 4%
- Dockerfile 0.5%
- HTML 0.1%
| Filename | Latest commit message | Latest commit date |
|---|---|---|
- Save the server URL as entered; derive the root (/health, /props) and the /v1 API base from it either way. - Health check only looks at the status code: llama-swap answers "OK". - Read per-model vision support and context size from /v1/models (llama-swap reports them), falling back to /props for a single plain llama-server. - Always send a model: llama-swap and router mode reject requests without one. With none saved, use the only model or the only vision model. - Admin model field is now a dropdown labelled with vision/context and preselects the vision model after a connection test. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Eq42wBXEXftpxYYfpBCq1n |
||
| .forgejo/workflows | ||
| backend | ||
| frontend | ||
| .env.example | ||
| .gitignore | ||
| docker-compose.override.yml | ||
| docker-compose.yml | ||
| README.md | ||
🍳 Recipe Manager
A self-hosted recipe manager: scan recipes from photos, store them in a local SQLite database, scale ingredients by servings, organize with tags, and push shopping lists to Home Assistant.
- Backend — Rust / axum + SQLite (
backend/) - Frontend — React + Vite single-page app (
frontend/)
Features
- 📷 Scan a recipe from a photo — pluggable OCR: uses Claude vision (best accuracy) when an API key is set, otherwise falls back to local Tesseract OCR with heuristic parsing.
- 🗂️ Source tracking — note where a recipe came from (family, cookbook, website, …) and the specific name (e.g. "Grandma", "Joy of Cooking").
- 🔢 Servings & scaling — set base servings; ingredient quantities scale up
or down on the fly, with friendly fractions (
2 1/4 cups). - 🛒 Export to Home Assistant — push the (scaled) ingredient list to a to-do / shopping-list entity via the HA REST API. Also a one-click "copy list".
- 👥 Multiple users — register / log in (JWT), or single sign-on via OIDC (e.g. Authentik) when configured. Existing accounts can link their SSO identity from Settings. Recipes are shared: everyone can see and cook every recipe, but only the user who added one can edit or delete it. Each user has their own Home Assistant connection settings.
- ❤️ Favorites & dislikes — each user can favorite recipes (with a Favorites filter) or mark ones they won't eat; a recipe shows who's a fan and who isn't.
- 🧑🤝🧑 Cook-for-the-group search — find recipes that a chosen set of people all like and that nobody in another set dislikes (e.g. "a dinner Garnet, Malea, and Wen all like").
- 📒 Cookbooks — each user can create any number of named cookbooks and add recipes by hand and/or via smart tag rules (auto-include everything matching the tags, "any" or "all"). Cookbooks are private to their owner.
- 🛡️ Admins — the first account is an admin and can create other users, promote/demote admins, and set any user's like/dislike on a recipe.
- 🖼️ Photo uploads — attach multiple photos to each recipe.
- 🏷️ Tags / categories — free-form keywords (breakfast, dessert, sandwich…) with click-to-filter on the recipe list.
Quick start
1. Backend
cd backend
# Needs a Rust toolchain (https://rustup.rs).
cp .env.example .env # set SECRET_KEY before exposing this anywhere
# (optional) set ANTHROPIC_API_KEY in .env to enable the Claude scanner
./run.sh # cargo run --release, serves on http://localhost:8000
cargo test # unit tests
The SQLite database (recipes.db) and uploads/ directory are created
automatically on first run.
2. Frontend
cd frontend
npm install
npm run dev # serves on http://localhost:5173
Open http://localhost:5173, create an account, and start adding recipes.
In dev, Vite proxies API paths to the backend on :8000, so there's nothing
else to configure.
Recipe scanning backends
The scanner defaults to SCAN_BACKEND in backend/.env; an admin can override
it (and the Claude key/model, Ollama or llama.cpp server/model) on the Admin page:
| Value | Behavior |
|---|---|
auto |
Claude if a key is set, else Ollama, else llama.cpp if configured, else Tesseract |
claude |
Force the Claude vision model (SCAN_MODEL, default Opus 4.8) |
ollama |
Force a vision model on a self-hosted Ollama server |
llamacpp |
Force a vision model on a self-hosted llama.cpp llama-server |
tesseract |
Force local OCR |
- Claude: just set
ANTHROPIC_API_KEY. Returns fully structured fields (title, ingredients split into qty/unit/name, instructions, servings, tags). - Ollama: on the Admin page, enter the server's
IP:port(e.g.192.168.1.10:11434), click Test connection to list its models, pick a vision-capable one (qwen3-vl,qwen2.5vl,llama3.2-vision,gemma3…) and save. Uses the same structured-JSON prompt as Claude. - llama.cpp: run
llama-serverwith a vision model and its projector, e.g.llama-server -m Qwen2.5-VL-7B-Q4_K_M.gguf --mmproj mmproj-Qwen2.5-VL-7B-f16.gguf --ctx-size 16384 --host 0.0.0.0 --port 8080. On the Admin page enter itsIP:port, click Test connection (it reports whether vision is enabled), and save. The model name is only needed in router mode; an API key only if the server was started with--api-key. Talks to the OpenAI-compatible/v1/chat/completionsendpoint, so other OpenAI-compatible servers work too. - Tesseract: install the system binary (
sudo pacman -S tesseract tesseract-data-eng,apt install tesseract-ocr, orbrew install tesseract). Raw text is parsed heuristically — expect to tidy up fields.
If none is available, scanning returns a clear error and you can still enter
recipes by hand. Check GET /api/health to see which backends are live.
Single sign-on (OIDC / Authentik)
SSO is optional and off by default — without it, the app uses its built-in username/password login. To enable it, set these in the backend env (Portainer stack env in production):
| Var | Example |
|---|---|
OIDC_ISSUER |
https://auth.example.com/application/o/recipes/ |
OIDC_CLIENT_ID |
from the Authentik provider |
OIDC_CLIENT_SECRET |
from the Authentik provider |
OIDC_REDIRECT_URI |
https://<your-host>/api/auth/oidc/callback |
OIDC_SCOPES |
openid email profile (default) |
OIDC_BUTTON_LABEL |
Sign in with Authentik (default) |
In Authentik: create an OAuth2/OpenID Provider, set its redirect URI to the
OIDC_REDIRECT_URI above, attach it to an Application, then copy the client id
and secret. The client secret stays on the backend and is never sent to the SPA.
Behavior:
- Password login stays available as a fallback (so the bootstrap admin is never locked out).
- Signing in via SSO with an identity that isn't linked yet auto-creates an account from the OIDC claims (the first account becomes the admin).
- Existing accounts link their SSO identity from Settings → Single sign-on; afterwards the SSO button signs them into that same account. You can unlink again (allowed only if the account also has a password, to avoid lockout).
Home Assistant export
In Settings, enter:
- Base URL — e.g.
http://homeassistant.local:8123 - Token — a long-lived access token (HA profile → Long-Lived Access Tokens)
- Entity — your list entity, e.g.
todo.shopping_list
Then on any recipe, pick the servings and click → Home Assistant. Each
ingredient is added via the todo.add_item service.
Docker
Both services are containerized. The frontend image runs nginx, which serves
the built SPA and reverse-proxies /api and /uploads to the backend — so the
whole app is reached on a single port.
cp .env.example .env # set SECRET_KEY (and ANTHROPIC_API_KEY if wanted)
docker compose up --build # UI on http://localhost:8080
- The backend image is a multi-stage build (Rust compile →
debian:bookworm-slim) and bundles Tesseract (with English data), so the offline scanner works out of the box; setANTHROPIC_API_KEYto use Claude instead. - SQLite DB and uploaded photos persist in the
recipe-datanamed volume (mounted at/data). FRONTEND_PORTcontrols the published port (default8080).
Deploy (Forgejo Actions + Portainer)
.forgejo/workflows/build-deploy.yml runs on every push to main (Markdown-only
changes are skipped):
- test-backend —
cargo test --lockedin the Rust toolchain image. - build-backend / build-frontend — buildx builds pushed to
git.thenymans.com, with the layer cache kept in the registry under a:buildcachetag so dependency builds are reused across runs. The backend is only built once its tests pass. - deploy — finds the Portainer stack by name (
STACK_NAME: recipie), reads its endpoint and env from the stack itself, pulls the new images onto that endpoint, and redeploys withdocker-compose.ymlfrom the repo, pinning the images to the commit SHA (IMAGE_TAG). It reuses the env vars already set on the stack, so secrets never need to be mirrored into CI. Git-backed stacks are redeployed through Portainer's git endpoint instead.
Images are published as:
git.thenymans.com/brian/recipe-backend:{latest, <sha>, buildcache}
git.thenymans.com/brian/recipe-frontend:{latest, <sha>, buildcache}
If your repo owner is not
brian, change the image names andREGISTRYin the workflow andIMAGE_NAMESPACEindocker-compose.ymlto match.
Required secrets on the Forgejo repo:
| Secret | Purpose |
|---|---|
REGISTRY_USER |
registry login user |
REGISTRY_PASSWORD |
registry login token/password |
PORTAINER_TOKEN |
Portainer API key |
On the Portainer stack, set the runtime env (SECRET_KEY, CORS_ORIGINS,
ANTHROPIC_API_KEY, FRONTEND_PORT, …). The workflow only overrides
IMAGE_TAG; everything else is preserved across deploys.
Project layout
backend/
src/
main.rs axum app, CORS, static uploads, healthcheck subcommand
config.rs env / .env settings
db.rs SQLite schema, startup migrations, admin bootstrap
models.rs row types (User, Recipe, Ingredient, Photo, Cookbook)
schemas.rs request/response bodies + validation
error.rs FastAPI-compatible errors and extractors
security.rs PBKDF2 password hashing + JWT, current-user extractors
scaling.rs servings scaling with fraction formatting
crud.rs persistence + serialization helpers
oidc.rs OIDC (Authentik) flow
settings_store.rs admin-editable scan settings
scanning/ pluggable Claude / Tesseract scanners + parser
routes/ auth, recipes, export, cookbooks, admin, scan/tags/users
frontend/
src/
api.js fetch client
auth.jsx auth context (token in localStorage)
pages/ Login, Recipes, RecipeDetail, RecipeForm, Settings
Notes
- Tables are created automatically on startup, and missing
userscolumns are added in place. The schema and timestamp format are the same as the original Python (FastAPI/SQLAlchemy) backend's, so an existingrecipes.db, its password hashes, and already-issued login tokens all keep working. - Passwords are hashed with PBKDF2-HMAC-SHA256 (240k iterations).
- Server address:
HOST(default0.0.0.0) andPORT(default8000). - Set a strong
SECRET_KEYand serve over HTTPS before exposing this beyond your LAN.