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
24 changes: 14 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Kork & Krone

**Last updated:** 10. November 2026
**Last updated:** 11 November 2026
**Submission:** 3 (first complete prototype, beta)
**Status:** In progress. See [Status for submission 3](#status-for-submission-3).

Expand All @@ -14,6 +14,8 @@ HOW TO MAINTAIN THIS FILE

Kork & Krone is a wine review site for students, inspired by Vivino. It is a group project in IT2810 Web Development at NTNU (group T18).

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.

- **Application:** [it2810-18.idi.ntnu.no/project2/](http://it2810-18.idi.ntnu.no/project2/). Requires the NTNU network or VPN.
Expand Down Expand Up @@ -52,8 +54,8 @@ Submission 3 should be the first complete prototype, with search, browsing, sort
| 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 | |
| Larger dataset on the VM | Done | |
| Continuous integration (CI) | Not yet started | Slim version: 1 007 wines and 150 000 ratings |
| Larger dataset on the VM | Done | Slim version: 1 007 wines and 150 000 ratings |
| Continuous integration (CI) | Not yet started | |

<!--
Update the backend row when it runs on the VM: "Done. Try it in Apollo Sandbox at /project2/graphql".
Expand Down Expand Up @@ -101,7 +103,7 @@ This section describes what users can do. "Backend" means the API supports the f
| Search | Done | Done | Ignores case and accents. Matches name, winery, region and grapes as one phrase. Waits 300 ms after the last key press |
| Filtering | Done | Done | Type, country, grapes, food pairing, minimum rating and alcohol range. Several values can be selected. The counts follow the search and the other filters. On small screens the filters open in a dialog |
| Sorting | Done | Done | Top rated, most rated, name and alcohol. Always sorts the whole result, not only the loaded page |
| Pagination | Done | Done | Cursor-based. The user loads more results with a button, not with infinite scroll. Focus moves to the first new wine |
| 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) |
Expand Down Expand Up @@ -134,7 +136,7 @@ Each row explains what we chose, why, and what else we considered. Added as the
| Styling | CSS Modules and design tokens in `styles/tokens.css` | No runtime cost and no extra dependency. Tokens make dark mode and consistent colours easy | Tailwind, styled-components |
| API | GraphQL with Apollo Server on Express | Required by the course. The client asks only for the fields it shows, which saves data | REST |
| Database | PostgreSQL with the `pg_trgm` extension | Fast text search with `ILIKE` also on many rows. Already available on the VM | MongoDB, SQLite |
| Pagination | Cursor-based, pages merged in the Apollo cache | Stable when sorting. No duplicates or gaps when new data is added | Offset-based |
| Pagination | GraphQL connection with an opaque cursor that holds an offset. Pages are merged in the Apollo cache | Simple, and works with every sort order. The frontend never reads the cursor, so we can switch to keyset pagination later without changing it | Keyset pagination: faster deep into large results, but harder to combine with many sort orders |
| Search, filtering and sorting | In the database | Scales to large datasets. The frontend never loads the whole catalogue | Filtering in the browser |
| Search state flow | Field text in React state, debounced into the URL, and the query reads only the URL | One source of truth for the search, so reload, shared links and the back button all give the same result | Sending a request directly from the input |
| Filter panel on small screens | Native `<dialog>` with `showModal()` | The browser handles focus trapping, Escape and returning focus, with no extra JavaScript | A dialog library |
Expand All @@ -157,7 +159,7 @@ We use the [X-Wines](https://github.com/rogerioxavier/X-Wines) dataset. It is re
| Version | Wines | Ratings | Used for |
|---|---|---|---|
| Test | 100 | 1 000 | Local development and automated tests |
| Slim | 1 007 | 150 000 | Planned for the VM |
| Slim | 1 007 | 150 000 | The VM |
| Full | 100 646 | about 21 million | Planned for load testing and to show that the solution scales |

Local development uses the Test version. The VM uses the Slim version, because it gives
Expand Down Expand Up @@ -224,9 +226,10 @@ We follow the principle from the course: measure, set a budget and show the numb
- Search, filtering, sorting and pagination run in the database. A page returns at most 50 wines.
- The Apollo cache, so we do not fetch the same data twice.
- Debounce on the search field (300 ms). An end-to-end test checks that a whole word sends only one search.
- Apache compresses HTML, CSS and JavaScript with gzip. The main JavaScript file goes from 435 kB to 136 kB.

**Planned:**
- Compression (gzip or Brotli) and cache headers in Apache.
- Cache headers in Apache.

### Budget and measurements

Expand All @@ -239,8 +242,8 @@ We follow the principle from the course: measure, set a budget and show the numb
| CO2 per visit | Not decided | Not measured yet | | CO2.js (Sustainable Web Design model) with the transferred bytes |

The search scenario is: open the landing page, search for "riesling", filter on red wine, and load one more page of results.
Lighthouse performance is low mainly because Apache does not compress files or set cache headers yet,
and because the test was run over VPN. These are the "before" numbers. We will measure again after enabling compression.
Lighthouse performance was low mainly because Apache did not compress files or set cache headers at the time,
and because the test was run over VPN. These are the "before" numbers. Compression is now on, and we will measure again.

## Testing

Expand Down Expand Up @@ -306,7 +309,8 @@ backend/src/
schema.ts GraphQL schema
resolvers.ts GraphQL resolvers
wine-query.ts builds the SQL for search, filtering and sorting
scripts/ database schema and import of X-Wines
scripts/ import of X-Wines
backend/migrations/ database migrations (node-pg-migrate)
```

### Language
Expand Down
File renamed without changes
File renamed without changes
65 changes: 37 additions & 28 deletions docs/tasks.md
Original file line number Diff line number Diff line change
@@ -1,47 +1,56 @@
# Tasks

Kork & Krone will help students search Vinmonopolet products and compare drinks.
The product catalog will come from a one-time API import into our own PostgreSQL database.
The application will then read product data through our backend.
Kork & Krone lets students search wines, compare their own die rolls with what the wine community thinks,
and keep a list of wines they want to try.
The catalog comes from the [X-Wines](https://github.com/rogerioxavier/X-Wines) dataset, imported into our own PostgreSQL database.
The frontend reads it through our GraphQL backend.

The planned stack is React/TypeScript with Vite, Apollo Client, GraphQL, Node.js,
and PostgreSQL. The current backend uses JavaScript, Express, and `pg`.
We first planned to use Vinmonopolet's product data, but the API gave too little data.
See the [API documentation](api.md) for why we switched.

The stack is React/TypeScript with Vite and Apollo Client, and a Node.js/TypeScript backend with
Apollo Server and PostgreSQL.

## Catalog

- [ ] Import product data from Vinmonopolet into PostgreSQL.
- [ ] Add a GraphQL API and Apollo Client.
- [ ] Add search results and a product page with details and reviews.
- [ ] Support case-insensitive searches for words and product names.
- [ ] Debounce search requests and avoid repeated requests.
- [ ] Return a limited number of results with offset or cursor pagination.
- [ ] Cache results so users can move between pages efficiently.
- [ ] Filter search results by categories and ranges.
- [ ] Show available result counts for each category and avoid filters that produce empty results.
- [ ] Keep pagination consistent with search and filters.
- [ ] Sort the complete result set by price, name, alcohol percentage, and other relevant fields.
- [ ] Perform search, filtering, sorting, and pagination in the backend/database.
- [ ] Support searches across millions of rows without loading all rows into the frontend.
- [x] Import the X-Wines dataset into PostgreSQL.
- [x] Add a GraphQL API and Apollo Client.
- [x] Add search results and a wine page with details.
- [x] Support case-insensitive searches for words and wine names.
- [x] Debounce search requests and avoid repeated requests.
- [x] Return a limited number of results at a time, with "load more".
- [x] Cache results so users can move between pages efficiently.
- [x] Filter search results by categories and ranges.
- [x] Show result counts for each filter value.
- [x] Keep pagination consistent with search and filters.
- [x] Sort the complete result set by rating, name and alcohol percentage.
- [x] Perform search, filtering, sorting and pagination in the backend/database.
- [ ] Test with the Full dataset (100 000 wines, 21 million ratings) to show that it scales.

## Reviews and usability

- [ ] Let users submit reviews or ratings through the backend.
- [ ] Store submissions persistently and show updated results in the frontend.
- [ ] Keep search, filter, and sorting choices after a page reload.
- [ ] Make the interface accessible.
- [ ] Limit unnecessary requests and resource use.
- [x] Let users submit reviews through the backend (die roll 1–6 and an optional comment).
- [x] Store reviews persistently in the database.
- [ ] Show reviews and the student average in the frontend, updated right after saving.
- [x] Keep search, filter and sorting choices after a page reload.
- [x] Make the interface accessible (WCAG 2.1 AA).
- [x] Limit unnecessary requests and resource use.

## Optional ideas

- Alcohol per krone (APK), calculated from price, volume, and alcohol percentage.
- Semantic search.
- A "Har prøvd" list for wines the user has tasted, next to the "Vil prøve" list.
- Search suggestions while typing.

## Sketches

Product page with reviews:
These are early drafts from before we switched to X-Wines, so they show Vinmonopolet prices, beer and spirits,
and a different colour scheme. The app has since got its own design, but the layout of the search results
and the wine page still follows them.

Wine page with reviews:

![Product page with reviews](../Produktside%20med%20anmeldelser.png)
![Wine page with reviews](sketches/product-page.png)

Search results:

![Search results](../S%C3%B8keresultat.png)
![Search results](sketches/search-results.png)