Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
18 changes: 9 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
@@ -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).

Expand All @@ -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.
Expand Down Expand Up @@ -44,16 +44,16 @@ 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 |
| Backend running on the VM | Done | Started with `nohup`, see [VM guide](docs/vm.md) |
| 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 | |

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion backend/src/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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."
Expand Down
4 changes: 2 additions & 2 deletions docs/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down
1 change: 1 addition & 0 deletions frontend/e2e/landing.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ const landingResponse = {
types: [{ __typename: 'FilterOption', value: 'Red', count: 100 }],
countries: [{ __typename: 'FilterOption', value: 'FR' }],
},
recentReviews: [],
},
};

Expand Down
15 changes: 15 additions & 0 deletions frontend/e2e/wine.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 });
});
}
Expand Down
2 changes: 1 addition & 1 deletion frontend/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@
<div id="root"></div>
<script type="module" src="/src/main.tsx"></script>
</body>
</html>
</html>
12 changes: 0 additions & 12 deletions frontend/src/components/ui/DiceFace.module.css

This file was deleted.

26 changes: 0 additions & 26 deletions frontend/src/components/ui/DiceFace.test.tsx

This file was deleted.

48 changes: 0 additions & 48 deletions frontend/src/components/ui/DiceFace.tsx

This file was deleted.

33 changes: 33 additions & 0 deletions frontend/src/components/ui/Stars.module.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
.stars {
display: inline-flex;
align-items: center;
}

.icons {
display: inline-flex;
gap: 2px;
}

.filled,
.empty {
flex-shrink: 0;
stroke-width: 1.5;
stroke-linejoin: round;
}

.filled {
fill: var(--color-brand);
stroke: var(--color-brand);
}

.empty {
fill: none;
stroke: var(--color-text-muted);
}

@media (prefers-color-scheme: dark) {
.filled {
fill: var(--cork-300);
stroke: var(--cork-300);
}
}
41 changes: 41 additions & 0 deletions frontend/src/components/ui/Stars.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import styles from './Stars.module.css';

const STAR_PATH =
'M12 2.5l2.94 5.96 6.56.95-4.75 4.63 1.12 6.54L12 17.5l-5.87 3.08 1.12-6.54L2.5 9.41l6.56-.95z';

/** One star. Hidden from screen readers, so the text next to it is what they read. */
export function StarIcon({ filled, size = 20 }: { filled: boolean; size?: number }) {
return (
<svg
width={size}
height={size}
viewBox="0 0 24 24"
className={filled ? styles.filled : styles.empty}
aria-hidden="true"
focusable="false"
>
<path d={STAR_PATH} />
</svg>
);
}

interface StarsProps {
/** 1–5. Rounded to whole stars. */
value: number;
size?: number;
}

/** A rating as five stars, with the text «4 av 5 stjerner» for screen readers. */
export function Stars({ value, size = 20 }: StarsProps) {
const filled = Math.min(5, Math.max(0, Math.round(value)));
return (
<span className={styles.stars}>
<span className={styles.icons} aria-hidden="true">
{[1, 2, 3, 4, 5].map((star) => (
<StarIcon key={star} filled={star <= filled} size={size} />
))}
</span>
<span className="sr-only">{filled} av 5 stjerner</span>
</span>
);
}
2 changes: 1 addition & 1 deletion frontend/src/components/ui/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
export { Bottle } from './Bottle';
export { ChipLink } from './Chip';
export { DiceFace } from './DiceFace';
export { StarIcon, Stars } from './Stars';
export { ErrorNotice } from './ErrorNotice';
export { HeartIcon } from './HeartIcon';
export { SearchForm } from './SearchForm';
Expand Down
1 change: 1 addition & 0 deletions frontend/src/features/landing/LandingPage.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ const mock = {
types: [{ __typename: 'FilterOption', value: 'Red', count: 100 }],
countries: [{ __typename: 'FilterOption', value: 'FR' }],
},
recentReviews: [],
},
},
};
Expand Down
4 changes: 2 additions & 2 deletions frontend/src/features/landing/LandingView.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -86,13 +86,13 @@ describe('LandingView – innhold', () => {
);
});

it('viser nye dommer med terningkast, kommentar og tidspunkt', () => {
it('viser nye dommer med stjerner, kommentar og tidspunkt', () => {
renderLoaded();
const region = screen.getByRole('region', { name: 'Nylig dømt' });
const items = within(region).getAllByRole('listitem');
expect(items).toHaveLength(5);
const first = items[0];
expect(within(first).getByText('Terningkast 5 av 5')).toBeInTheDocument();
expect(within(first).getByText('5 av 5 stjerner')).toBeInTheDocument();
expect(within(first).getByRole('link', { name: 'Chianti Classico Riserva' })).toHaveAttribute(
'href',
'/vin/111427',
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/features/landing/LandingView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ export function LandingView({ data, loading, error, refetch, now }: LandingViewP
<Section
id="recent"
title="Nylig dømt"
description="De siste terningkastene fra studenter på Kork & Krone."
description="De siste dommene fra studenter på Kork & Krone."
>
<RecentReviews reviews={data.recentReviews} now={now} />
</Section>
Expand Down
12 changes: 12 additions & 0 deletions frontend/src/features/landing/api/landingQuery.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,17 @@ export const LANDING_QUERY = gql`
value
}
}
recentReviews(first: 5) {
id
rating
comment
author
createdAt
wine {
id
name
type
}
}
}
`;
18 changes: 16 additions & 2 deletions frontend/src/features/landing/api/toLandingData.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ const query = (wines: ApiWine[] = [wine('1')]): LandingQueryData => ({
],
countries: [{ value: 'FR' }, { value: 'IT' }],
},
recentReviews: [],
});

describe('toLandingData', () => {
Expand All @@ -45,7 +46,20 @@ describe('toLandingData', () => {
expect(topRated.map((w) => w.id)).toEqual(['1', '3']);
});

it('has no recent reviews until the API supports them', () => {
expect(toLandingData(query()).recentReviews).toEqual([]);
it('maps recent reviews and leaves out wines with an unknown type', () => {
const review = (id: string, type: string) => ({
id,
rating: 4,
comment: null,
author: 'Student #1',
createdAt: '2026-11-12T10:00:00.000Z',
wine: { id: '1', name: 'Wine 1', type },
});
const { recentReviews } = toLandingData({
...query(),
recentReviews: [review('a', 'Red'), review('b', 'Orange')],
});
expect(recentReviews.map((r) => r.id)).toEqual(['a']);
expect(recentReviews[0].wine.type).toBe('RED');
});
});
Loading