diff --git a/README.md b/README.md index 477fc1e..9824fe7 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # Kork & Krone -**Last updated:** 11 November 2026 +**Last updated:** 12 November 2026 **Submission:** 3 (first complete prototype, beta) **Status:** In progress. See [Status for submission 3](#status-for-submission-3). @@ -16,7 +16,7 @@ Kork & Krone is a wine review site for students, inspired by Vivino. It is a gro The app is in Norwegian, because its users are Norwegian students. The code and the documentation are in English, as is common in software projects. -Students can search, filter and sort a catalogue of wines. Each wine shows two ratings side by side: the community rating from the X-Wines dataset and the rating from other students. Students give their own verdict as a die roll from 1 to 6. +Students can search, filter and sort a catalogue of wines. Each wine shows two ratings side by side: the community rating from the X-Wines dataset and the rating from other students. Students give their own verdict as 1 to 5 stars. - **Application:** [it2810-18.idi.ntnu.no/project2/](http://it2810-18.idi.ntnu.no/project2/). Requires the NTNU network or VPN. - **GraphQL API:** `/project2/graphql` on the VM, `localhost:3001/graphql` locally. @@ -44,7 +44,7 @@ Submission 3 should be the first complete prototype, with search, browsing, sort | Area | Status | Note | |---|---|---| -| Landing page | Done | Shows real data from the API. Reviews are hidden until the API supports them | +| Landing page | Done | Shows real data from the API, including the newest student reviews under «Nylig dømt» | | GraphQL API: search, filter, sort, pagination | Done | Queries `wines`, `wine` and `filterOptions` | | Database schema and X-Wines Test import | Done | 100 wines and 1 000 ratings | | Frontend deployed on the VM | Done | Deep links such as `/project2/sok` work on reload | @@ -52,8 +52,8 @@ Submission 3 should be the first complete prototype, with search, browsing, sort | Apollo Client in the frontend | Done | | | Search page with results | Done | Search with debounce, number of hits and "Last inn flere" at `/sok` | | Filtering and sorting in the user interface | Done | Filter panel, active filters and sorting on `/sok`. Needs the new backend on the VM | -| Wine detail page | Done | Facts, food pairing and rating at `/vin/:id`. Student reviews are added with the reviews feature | -| Student reviews (stored in the database) | Planned | | +| Wine detail page | Done | Facts, food pairing, the community rating and student reviews at `/vin/:id`. Student reviews are added with the reviews feature | +| Student reviews (stored in the database) | Done | 1–5 stars and an optional comment, saved and shown at once on the wine page | | Larger dataset on the VM | Done | Slim version: 1 007 wines and 150 000 ratings | | Continuous integration (CI) | Not yet started | | @@ -105,10 +105,10 @@ This section describes what users can do. "Backend" means the API supports the f | Sorting | Done | Done | Top rated, most rated, name and alcohol. Always sorts the whole result, not only the loaded page | | Pagination | Done | Done | Pages behind an opaque cursor that holds an offset. The user loads more results with a button, not with infinite scroll. Focus moves to the first new wine | | Search state in the URL | Not needed | Done | `?q=&type=&land=&drue=&mat=&vurdering=&alkohol=&sort=`. Survives reloads. Typing replaces the history entry, so the back button leaves the search instead of stepping through every word | -| Wine detail page | Done (`wine(id)`) | Done | Name, winery, region, grapes, alcohol, body, acidity, vintages and food pairing in Norwegian. Grapes and food link to the search. Student reviews are planned | -| Student reviews | Planned | Planned | Die roll from 1 to 6 and an optional comment, stored in PostgreSQL, the new rating is shown at once without a reload (Apollo cache update) | +| Wine detail page | Done (`wine(id)`) | Done | Name, winery, region, grapes, alcohol, body, acidity, vintages and food pairing in Norwegian. Grapes and food link to the search. | +| Student reviews | Done | Done | 1–5 stars and an optional comment, stored in PostgreSQL. The average and the list update at once without a reload. One review per student per wine | | Wishlist ("Vil prøve") | Planned | Done, stored in the browser | Moves to the backend when users and reviews are in place | -| User | Planned | Planned | Login or anonymous ID stored in browser | +| User | Done (Anonymous ID) | Done | An anonymous ID stored in browser until we have login (#29) | ## Architecture and technology choices @@ -354,7 +354,7 @@ Claude and ChatGPT are the main models used. The usecases for the AI tools are a ### Then: towards the next submission -- [ ] Student reviews: GraphQL mutation, database table, validation, and the new rating shown at once. +- [x] Student reviews: GraphQL mutation, database table, validation, and the new rating shown at once. - [ ] Wishlist stored in the backend. - [x] Larger dataset on the VM. - [ ] Load test with the Full dataset. diff --git a/backend/src/schema.ts b/backend/src/schema.ts index 5f8cf93..b5710fa 100644 --- a/backend/src/schema.ts +++ b/backend/src/schema.ts @@ -86,7 +86,7 @@ export const typeDefs = `#graphql type Review { id: ID! - "Rating 0 to 5." + "Rating 1 to 5." rating: Int! comment: String "Display name such as 'Student #4821'. The user ID is never shown." diff --git a/docs/api.md b/docs/api.md index 43ae1b2..387f5b9 100644 --- a/docs/api.md +++ b/docs/api.md @@ -56,8 +56,8 @@ During development, Vite forwards `/graphql` to the backend. On the VM, Apache f ## Student reviews -A review is a die roll from 1 to 6 and an optional comment (max 500 characters). -There is no login yet, so the frontend creates a random UUID once (`crypto.randomUUID()`), +A review is 1 to 5 stars and an optional comment (max 500 characters). +There is no login yet, so the frontend creates a random UUID once (`crypto.randomUUID()`, or random bytes on plain HTTP, where `randomUUID` does not exist), stores it in localStorage and sends it as `userId`. Treat it like a password: the API never returns it, reviews are shown with a display name such as "Student #12". Every student gets their own number the first time they save a review, so two students never share a name. diff --git a/frontend/e2e/landing.spec.ts b/frontend/e2e/landing.spec.ts index 56e630b..ceee7fe 100644 --- a/frontend/e2e/landing.spec.ts +++ b/frontend/e2e/landing.spec.ts @@ -30,6 +30,7 @@ const landingResponse = { types: [{ __typename: 'FilterOption', value: 'Red', count: 100 }], countries: [{ __typename: 'FilterOption', value: 'FR' }], }, + recentReviews: [], }, }; diff --git a/frontend/e2e/wine.spec.ts b/frontend/e2e/wine.spec.ts index 43011c9..204616f 100644 --- a/frontend/e2e/wine.spec.ts +++ b/frontend/e2e/wine.spec.ts @@ -45,6 +45,21 @@ async function stubApi(page: Page) { json: { data: { wine: variables.id === wine.id ? wine : null } }, }); } + if (operationName === 'WineReviews') { + return route.fulfill({ + json: { + data: { + wine: { + __typename: 'Wine', + id: wine.id, + studentRating: { __typename: 'StudentRating', average: null, count: 0 }, + reviews: [], + }, + myReview: null, + }, + }, + }); + } return route.fulfill({ json: searchResult }); }); } diff --git a/frontend/index.html b/frontend/index.html index 7671861..65df8c5 100644 --- a/frontend/index.html +++ b/frontend/index.html @@ -14,4 +14,4 @@