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
46 changes: 38 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@ details, ratings, reviews and a personal wantlist ("crate") are also planned.

IT2810 (NTNU) Project 2. Group T19: `erikhfj`, `robertky`, `evenkkl`, `rachelks`.

| | |
| ----------------- | --------------------------------------------------------- |
| Current milestone | **M2 – PostgreSQL and GraphQL on the VM**, due 16 October |
| Live prototype | http://it2810-19.idi.ntnu.no/project2 |
| Workflow | [`docs/WORKFLOW.md`](docs/WORKFLOW.md) |
| AI usage log | [`docs/AI-USAGE.md`](docs/AI-USAGE.md) |
| Running on the VM | [`docs/VM-setup.md`](docs/VM-setup.md) |
| | |
| ----------------- | -------------------------------------------------------------------------------- |
| Current milestone | **M3 – Beta: search, paging, sorting, filtering, accessibility**, due 30 October |
| Live prototype | http://it2810-19.idi.ntnu.no/project2 |
| Workflow | [`docs/WORKFLOW.md`](docs/WORKFLOW.md) |
| AI usage log | [`docs/AI-USAGE.md`](docs/AI-USAGE.md) |
| Running on the VM | [`docs/VM-setup.md`](docs/VM-setup.md) |

## Getting started

Expand Down Expand Up @@ -127,6 +127,36 @@ In local testing on 16 October 2026, using PostgreSQL 16 and 100,000 generated a

The first three timings are SQL queries; the last is a GraphQL HTTP response. These results were measured locally, not on the VM, and may differ on other hardware.

### Sustainability measures

Bærekraft here means design choices we can point at rather than claims, so each one is listed with a number.

| Measure | Why it saves work | Effect |
| ------------------------------- | -------------------------------------------------------- | --------------------------------------------------- |
| Plain CSS, no UI framework | No component-library runtime to download or parse | 0 UI dependencies in the bundle |
| `prefers-color-scheme` | OLED screens draw less power on a dark pixel | Dark theme when the OS asks for it |
| `prefers-reduced-motion` | Animations cost frames and battery | Collapsed to near-zero when the OS asks for it |
| Nothing until Search is pressed | Typing would otherwise cost one request per change | `skipToken` holds the query back, so typing is free |
| `cache-first` fetch policy | A repeated search is already in the cache | 0 requests when the answer is cached |
| Code-split album route | The detail page is not needed to browse search results | Separate 3.73 kB chunk, kept out of the main bundle |
| Bundle budget in CI | CI fails before a dependency quietly doubles the payload | 512 000 bytes per JS chunk |

**Bundle size**, production build measured 21 October 2026:

| File | Raw | Gzip |
| ----------------------- | --------: | --------: |
| `index-*.js` | 425.02 kB | 129.12 kB |
| `index-*.css` | 4.85 kB | 1.73 kB |
| `AlbumDetailPage-*.js` | 3.73 kB | 1.30 kB |
| `AlbumDetailPage-*.css` | 1.26 kB | 0.53 kB |
| `index.html` | 0.51 kB | 0.31 kB |

The two `AlbumDetailPage` rows are the chunk added by the album detail route (#11) and are not part of the search page payload. Note that the album link is a full page load today, so opening an album re-downloads the main bundle as well; the split still keeps the detail page out of the initial payload.

**Requests for a typical search: one.** The client has exactly one `useQuery`, so a search is a single `searchAlbums` request. Nothing is sent while the page is idle and nothing while the user types. Searching again for something already in the cache sends nothing. Opening an album is one further `album(id:)` request.

**Accessibility and bærekraft pull in the same direction here.** No request until Search is pressed is also why the result count is announced once instead of on every keystroke, and `prefers-reduced-motion` costs nothing for anyone who does not ask for it.

## Project status

| Milestone | Due | Delivers |
Expand All @@ -147,7 +177,7 @@ The first three timings are SQL queries; the last is a GraphQL HTTP response. Th

**Implemented:** The PostgreSQL database includes albums, artists, genres, tracks, users, reviews and crate items. The GraphQL backend supports album and artist search, genre and decade filters, sorting and cursor-based pagination. Supported sorts are `RELEVANCE`, `TITLE_ASC` and `RELEASE_YEAR_DESC`. `AVERAGE_RATING_DESC` is defined in the schema but currently returns an error because reviews are not implemented yet.

The frontend supports searching by album title or artist, with a 300 ms debounce, Enter/Search submission, loading and error feedback, and a no-results message. It currently shows the first 20 matches ordered by relevance.
The frontend supports searching by album title or artist, committed on Search or Enter rather than while typing, with loading and error feedback, and a no-results message. It currently shows the first 20 matches ordered by relevance.

**Planned:** Frontend filters, sorting, pagination controls and album details; reviews, ratings and wantlist functionality; accessibility and sustainability work (M3); and Playwright end-to-end tests (M4). The database tables for reviews and crate items exist, but their GraphQL functionality is still planned. `X-User-Id` is also defined but not yet handled at runtime.

Expand Down
8 changes: 4 additions & 4 deletions client/src/App.css
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
left: 0.5rem;
}
.site-header {
background: #181e1b;
color: #f7f5ef;
background: var(--header-bg);
color: var(--header-text);
}
.navigation {
max-width: 1240px;
Expand All @@ -26,7 +26,7 @@
text-decoration: none;
}
.navigation a[aria-current] {
border-bottom: 2px solid #a9c3a3;
border-bottom: 2px solid var(--header-accent);
padding-block: 0.4rem;
}
.brand {
Expand All @@ -35,7 +35,7 @@
letter-spacing: -0.08rem;
}
.brand span {
color: #a9c3a3;
color: var(--header-accent);
font-size: 0.65rem;
margin-left: 0.25rem;
}
Expand Down
4 changes: 2 additions & 2 deletions client/src/components/AlbumCard.css
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@
gap: 0.3rem;
}
.genre-tags li {
background: #eff0e9;
color: #50574c;
background: var(--chip-bg);
color: var(--chip-text);
border-radius: 4px;
padding: 0.15rem 0.4rem;
font-size: 0.8rem;
Expand Down
2 changes: 1 addition & 1 deletion client/src/components/ResultsLayout.css
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
.empty-state {
text-align: center;
padding: 3rem 1rem;
border: 1px dashed #b7bfb3;
border: 1px dashed var(--border-strong);
border-radius: 8px;
}
.empty-state p {
Expand Down
2 changes: 1 addition & 1 deletion client/src/components/SearchForm.css
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
width: 100%;
min-width: 0;
padding: 0.9rem 1rem;
border: 1px solid #b7bfb3;
border: 1px solid var(--border-strong);
border-radius: 6px;
background: var(--surface);
color: var(--text);
Expand Down
41 changes: 39 additions & 2 deletions client/src/global.css
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,15 @@
--text: #202824;
--muted: #61665e;
--accent: #285943;
--accent-hover: #1c4230;
--accent-text: #ffffff;
--border: #dedfd5;
--border-strong: #b7bfb3;
--chip-bg: #eff0e9;
--chip-text: #50574c;
--header-bg: #181e1b;
--header-text: #f7f5ef;
--header-accent: #a9c3a3;
--focus: #2874c5;
font-family:
system-ui,
Expand All @@ -15,6 +23,35 @@
line-height: 1.5;
font-synthesis: none;
}
/*
* Dark theme. One of the bærekraft measures: an OLED screen draws measurably
* less power on a dark pixel than a light one, so a dark theme is not only a
* preference, it is energy saved for anyone whose system asks for it.
*
* The light values above are untouched; these only override them when the OS
* reports a dark preference. Contrast is AA or better for every text pair and
* 3:1 or better for the form-control borders.
*/
@media (prefers-color-scheme: dark) {
:root {
color-scheme: dark;
--bg: #141814;
--surface: #1c211c;
--text: #ecefe9;
--muted: #a4ab9f;
--accent: #7fc9a0;
--accent-hover: #a5dcbb;
--accent-text: #12261c;
--border: #3a443a;
--border-strong: #6b766b;
--chip-bg: #262d26;
--chip-text: #c3cabc;
--header-bg: #0e120e;
--header-text: #ecefe9;
--header-accent: #7fc9a0;
--focus: #79b8f0;
}
}
* {
box-sizing: border-box;
}
Expand Down Expand Up @@ -65,11 +102,11 @@ button {
}
.primary-button {
background: var(--accent);
color: white;
color: var(--accent-text);
border: 1px solid var(--accent);
}
.primary-button:hover {
background: #1c4230;
background: var(--accent-hover);
}
.results h2 {
margin: 0;
Expand Down
10 changes: 9 additions & 1 deletion client/src/hooks/useAlbumSearch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,15 @@ export function useAlbumSearch() {
// Apollo owns server data; the URL owns what was asked for.
const { data, loading, error, refetch, networkStatus } = useQuery(
SEARCH_ALBUMS,
hasQuery ? { variables: { input, first: PAGE_SIZE, after: null } } : skipToken,
hasQuery
? {
variables: { input, first: PAGE_SIZE, after: null },
// Named rather than inherited. cache-first is Apollo's default, but
// spelling it out keeps the promise a repeated search costs no request
// at all, which is one of the bærekraft measures listed in the README.
fetchPolicy: 'cache-first',
}
: skipToken,
);

const retry = useCallback(() => {
Expand Down