Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
8fd5537
Style/improve UI consistency (#63)
olestan Oct 29, 2026
71dc93f
Chore/add seeded recipes (#62)
olestan Oct 29, 2026
e0e3bcb
Hasan/fix/review accessibility performance (#65)
hasanmo Nov 12, 2026
ca08816
Merge branch 'main' into dev
oliveror Nov 12, 2026
80e0211
fix(a11y): give the recipe not-found page an h1
oliveror Nov 16, 2026
ab0b2b3
test(e2e): make keyboard select tests pass on macOS
oliveror Nov 16, 2026
2e1557c
chore(build): support Node 24 and newer
oliveror Nov 16, 2026
aa91793
docs: document image sources and licenses
olestan Nov 16, 2026
008c5b4
chore(api): keep GraphiQL on by default and document why (#95)
oliveror Nov 16, 2026
f323fa1
fix(recipe): never show small scaled amounts as 0
oliveror Nov 16, 2026
dc409b9
fix(a11y): raise brand colour contrast to WCAG AA (#86)
oliveror Nov 16, 2026
618cd08
test(recipe): verify that clicking a card image opens the recipe (#90)
oliveror Nov 16, 2026
a1de47d
fix(a11y): move focus to the results after a page change (#91)
oliveror Nov 16, 2026
84df0f6
chore(web): remove dead code and mount review pages in dev only (#92)
oliveror Nov 16, 2026
0d0eaf7
chore(data): write real seed descriptions and seed demo ratings (#94)
oliveror Nov 16, 2026
de09b4a
feat(perf): cache images and assets, serve and normalise image varian…
oliveror Nov 16, 2026
8f64572
feat(perf): cut initial JavaScript for Explore by about a third (#93)
oliveror Nov 17, 2026
00c4033
fix(a11y): make ingredient and step reordering keyboard accessible (#…
oliveror Nov 17, 2026
608fdf6
fix(recipe): use one servings limit everywhere and allow typing it (#…
oliveror Nov 17, 2026
51b513e
fix(recipe): use English ingredient units with legacy mapping (#109)
oliveror Nov 17, 2026
dcf561f
feat(a11y): add a skip-to-content link (#112)
oliveror Nov 17, 2026
e076311
feat(a11y): set page titles and move focus to main on navigation (#113)
oliveror Nov 17, 2026
ff45ebe
feat(recipe): persist recipe drafts across navigation and reload (#115)
oliveror Nov 17, 2026
bd69fcb
fix(a11y): move focus to the recipe when using Jump to recipe (#116)
oliveror Nov 17, 2026
79a588a
feat(recipe): refresh stale data when returning to a long-open page (…
oliveror Nov 17, 2026
e4089c6
test(e2e): split the integrated browser test into independent scenari…
oliveror Nov 17, 2026
2dc2c2d
feat(search): indexed word search over recipes, ingredients and tags;…
oliveror Nov 17, 2026
36fa3eb
fix(recipe): check the API's size limits in the form; focus any inval…
oliveror Nov 17, 2026
3586c34
fix(recipe): protect recipe edits from conflicts, leaving and sign-ou…
oliveror Nov 17, 2026
3efaac0
feat(api): limit requests, query size and recipe creation; batch inse…
oliveror Nov 17, 2026
bfb5b89
docs(setup): document demo seeding and lecturer access (#126)
hasanmo Nov 18, 2026
c536999
docs(workflow): clarify branch and commit naming guidelines (#127)
hasanmo Nov 18, 2026
7a524a9
docs(api): explain request handling and recipe repository (#128)
hasanmo Nov 18, 2026
045ea5a
docs(process): clarify development support and verification (#129)
hasanmo Nov 18, 2026
58bee84
docs(project): align final documentation and stabilize form tests
hasanmo Nov 19, 2026
a62f7c8
Make README shorter and easier to navigate
hasanmo Nov 20, 2026
d5ab8e6
Improve recipe editing feedback and search filter validation
olestan Nov 20, 2026
e88f5f5
Fix recipe return navigation and cookbook search (#134)
oliveror Nov 20, 2026
a57ee13
chore: merge main into dev
Nov 20, 2026
d96ebf9
docs(readme): document Claude Code usage (#136)
oliveror Nov 21, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,7 @@ API_PORT=3001
AUTH_TRUST_PROXY=false
# false for localhost/current HTTP VM; true when HTTPS is configured.
AUTH_COOKIE_SECURE=false
# GraphiQL editor at /graphql is on unless this is false (see README).
# API_GRAPHIQL=false
# Optional absolute directory for persisted recipe images (default: uploads/ at project root).
# UPLOAD_DIR=/var/lib/recipe-platform/uploads
339 changes: 170 additions & 169 deletions README.md

Large diffs are not rendered by default.

131 changes: 131 additions & 0 deletions apps/api/migrations/0005_recipe_search_and_ratings.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,131 @@
ALTER TABLE "project2"."recipes" ADD COLUMN "rating_avg" numeric;--> statement-breakpoint
ALTER TABLE "project2"."recipes" ADD COLUMN "rating_count" integer DEFAULT 0 NOT NULL;--> statement-breakpoint
ALTER TABLE "project2"."recipes" ADD COLUMN "search_vector" "tsvector" DEFAULT ''::tsvector NOT NULL;--> statement-breakpoint
CREATE INDEX "recipes_public_category_created_idx" ON "project2"."recipes" USING btree ("category","created_at" DESC NULLS FIRST,"id" DESC NULLS FIRST) WHERE "project2"."recipes"."visibility" = 'public';--> statement-breakpoint
CREATE INDEX "recipes_public_total_time_idx" ON "project2"."recipes" USING btree (("prep_minutes" + "cook_minutes"),"created_at" DESC NULLS FIRST,"id" DESC NULLS FIRST) WHERE "project2"."recipes"."visibility" = 'public';--> statement-breakpoint
CREATE INDEX "recipes_public_rating_idx" ON "project2"."recipes" USING btree ("rating_avg" DESC NULLS LAST,"created_at" DESC NULLS FIRST,"id" DESC NULLS FIRST) WHERE "project2"."recipes"."visibility" = 'public';--> statement-breakpoint
CREATE INDEX "recipes_search_idx" ON "project2"."recipes" USING gin ("search_vector");
--> statement-breakpoint
-- Keep recipes.rating_avg/rating_count in step with ratings for every write
-- path (API, seed, manual SQL), so the highest-rated sort can use an index.
-- The recipe row is locked before counting. A concurrent rating of the same
-- recipe then waits until this one commits, and its count (a new snapshot,
-- since this is a separate statement) includes this rating instead of
-- overwriting the cache with a stale value. A rating moved to another recipe
-- refreshes both recipes, locked in id order so two moves cannot deadlock.
CREATE FUNCTION "project2"."refresh_recipe_rating"() RETURNS trigger
LANGUAGE plpgsql AS $$
DECLARE
target uuid;
BEGIN
FOR target IN
SELECT DISTINCT changed.id FROM unnest(ARRAY[
CASE WHEN TG_OP <> 'INSERT' THEN OLD.recipe_id END,
CASE WHEN TG_OP <> 'DELETE' THEN NEW.recipe_id END
]) AS changed(id)
WHERE changed.id IS NOT NULL ORDER BY changed.id
LOOP
PERFORM 1 FROM "project2"."recipes" WHERE id = target FOR NO KEY UPDATE;
UPDATE "project2"."recipes" r
SET rating_avg = s.average, rating_count = s.total
FROM (
SELECT avg(score) AS average, count(*)::int AS total
FROM "project2"."ratings" WHERE recipe_id = target
) s
WHERE r.id = target;
END LOOP;
RETURN NULL;
END $$;
--> statement-breakpoint
CREATE TRIGGER ratings_refresh_recipe_rating
AFTER INSERT OR UPDATE OF score, recipe_id OR DELETE ON "project2"."ratings"
FOR EACH ROW EXECUTE FUNCTION "project2"."refresh_recipe_rating"();
--> statement-breakpoint
-- Backfill existing ratings.
UPDATE "project2"."recipes" r
SET rating_avg = s.average, rating_count = s.total
FROM (
SELECT recipe_id, avg(score) AS average, count(*)::int AS total
FROM "project2"."ratings" GROUP BY recipe_id
) s
WHERE r.id = s.recipe_id;
--> statement-breakpoint
-- A new rating must not change the recipe's "last updated" time: fire the
-- touch trigger only when recipe content (or updated_at itself) is written.
DROP TRIGGER recipes_touch_updated_at ON "project2"."recipes";
--> statement-breakpoint
CREATE TRIGGER recipes_touch_updated_at
BEFORE UPDATE OF title, description, image_url, category, cuisine, difficulty,
visibility, prep_minutes, cook_minutes, servings, source_recipe_id, author_id,
updated_at
ON "project2"."recipes"
FOR EACH ROW EXECUTE FUNCTION "project2"."touch_updated_at"();
--> statement-breakpoint
-- Full-text search document: title, description, ingredient names and tags.
CREATE FUNCTION "project2"."recipe_search_document"(recipe uuid, title text, description text)
RETURNS tsvector LANGUAGE sql STABLE AS $$
SELECT to_tsvector('simple', concat_ws(' ', title, description,
(SELECT string_agg(i.name, ' ') FROM "project2"."recipe_ingredients" i WHERE i.recipe_id = recipe),
(SELECT string_agg(t.tag, ' ') FROM "project2"."recipe_tags" t WHERE t.recipe_id = recipe)))
$$;
--> statement-breakpoint
CREATE FUNCTION "project2"."set_recipe_search_vector"() RETURNS trigger
LANGUAGE plpgsql AS $$
BEGIN
NEW.search_vector := "project2"."recipe_search_document"(NEW.id, NEW.title, NEW.description);
RETURN NEW;
END $$;
--> statement-breakpoint
CREATE TRIGGER recipes_set_search_vector
BEFORE INSERT OR UPDATE OF title, description ON "project2"."recipes"
FOR EACH ROW EXECUTE FUNCTION "project2"."set_recipe_search_vector"();
--> statement-breakpoint
-- Statement-level: one refresh per INSERT/UPDATE/DELETE statement on
-- ingredients or tags, for every recipe the statement touched. An UPDATE that
-- moves rows to another recipe refreshes both the old and the new recipe.
-- As for ratings, the recipes are locked (in id order, so concurrent writers
-- cannot deadlock) before the document is rebuilt in a new snapshot, so a
-- concurrent ingredient or tag write is never overwritten by stale words.
CREATE FUNCTION "project2"."refresh_recipe_search_vector"() RETURNS trigger
LANGUAGE plpgsql AS $$
DECLARE
targets uuid[];
BEGIN
IF TG_OP = 'INSERT' THEN
SELECT array_agg(DISTINCT recipe_id) INTO targets FROM new_rows;
ELSIF TG_OP = 'DELETE' THEN
SELECT array_agg(DISTINCT recipe_id) INTO targets FROM old_rows;
ELSE
SELECT array_agg(recipe_id) INTO targets FROM (
SELECT recipe_id FROM old_rows UNION SELECT recipe_id FROM new_rows
) touched;
END IF;
PERFORM 1 FROM "project2"."recipes"
WHERE id = ANY(targets) ORDER BY id FOR NO KEY UPDATE;
UPDATE "project2"."recipes" r
SET search_vector = "project2"."recipe_search_document"(r.id, r.title, r.description)
WHERE r.id = ANY(targets);
RETURN NULL;
END $$;
--> statement-breakpoint
CREATE TRIGGER recipe_ingredients_search_insert AFTER INSERT ON "project2"."recipe_ingredients"
REFERENCING NEW TABLE AS new_rows FOR EACH STATEMENT EXECUTE FUNCTION "project2"."refresh_recipe_search_vector"();
--> statement-breakpoint
CREATE TRIGGER recipe_ingredients_search_update AFTER UPDATE ON "project2"."recipe_ingredients"
REFERENCING OLD TABLE AS old_rows NEW TABLE AS new_rows FOR EACH STATEMENT EXECUTE FUNCTION "project2"."refresh_recipe_search_vector"();
--> statement-breakpoint
CREATE TRIGGER recipe_ingredients_search_delete AFTER DELETE ON "project2"."recipe_ingredients"
REFERENCING OLD TABLE AS old_rows FOR EACH STATEMENT EXECUTE FUNCTION "project2"."refresh_recipe_search_vector"();
--> statement-breakpoint
CREATE TRIGGER recipe_tags_search_insert AFTER INSERT ON "project2"."recipe_tags"
REFERENCING NEW TABLE AS new_rows FOR EACH STATEMENT EXECUTE FUNCTION "project2"."refresh_recipe_search_vector"();
--> statement-breakpoint
CREATE TRIGGER recipe_tags_search_update AFTER UPDATE ON "project2"."recipe_tags"
REFERENCING OLD TABLE AS old_rows NEW TABLE AS new_rows FOR EACH STATEMENT EXECUTE FUNCTION "project2"."refresh_recipe_search_vector"();
--> statement-breakpoint
CREATE TRIGGER recipe_tags_search_delete AFTER DELETE ON "project2"."recipe_tags"
REFERENCING OLD TABLE AS old_rows FOR EACH STATEMENT EXECUTE FUNCTION "project2"."refresh_recipe_search_vector"();
--> statement-breakpoint
-- Backfill existing recipes.
UPDATE "project2"."recipes"
SET search_vector = "project2"."recipe_search_document"(id, title, description);
16 changes: 16 additions & 0 deletions apps/api/migrations/0006_recipe_title_subwords.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
-- Ordinary words keep PostgreSQL's default D weight. B marks only fragments
-- from inside title words, so the same GIN index can find both match groups.
CREATE OR REPLACE FUNCTION "project2"."recipe_search_document"(recipe uuid, title text, description text)
RETURNS tsvector LANGUAGE sql STABLE AS $$
SELECT to_tsvector('simple', concat_ws(' ', title, description,
(SELECT string_agg(i.name, ' ') FROM "project2"."recipe_ingredients" i WHERE i.recipe_id = recipe),
(SELECT string_agg(t.tag, ' ') FROM "project2"."recipe_tags" t WHERE t.recipe_id = recipe)))
|| setweight(to_tsvector('simple', coalesce((
SELECT string_agg(substr(word, start_pos), ' ')
FROM unnest(tsvector_to_array(to_tsvector('simple', title))) AS words(word)
CROSS JOIN LATERAL generate_series(2, char_length(word) - 2) AS offsets(start_pos)
), '')), 'B')
$$;
--> statement-breakpoint
UPDATE "project2"."recipes" r
SET search_vector = "project2"."recipe_search_document"(r.id, r.title, r.description);
Loading