Skip to content
Merged
Show file tree
Hide file tree
Changes from 13 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
4 changes: 3 additions & 1 deletion docs/accessibility.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@

- **Semantic HTML.** The page language is set (`<html lang="en">`), the main navigation is a `<nav>` with a label, and related form controls are grouped. For example, the page count filter uses a `<fieldset>` with a `<legend>`. This gives screen readers a structure to navigate by.

- **Accessible components.** Our UI components are built on Base UI (through shadcn/ui), which handles keyboard navigation, focus and ARIA attributes for components like dialogs, comboboxes, selects and sliders. Buttons and inputs show a visible focus ring when they are reached with the keyboard.
- **`<div>` and `<span>` only where no semantic element fits.** The few `<div>` and `<span>` elements that remain in our own components are there on purpose. Each `<div>` and `<span>` that remains in our own components has a short comment in the code that explains what it is used for and why it is still needed. When an element describes the content, we use it: every page has a `<main>` and its own headings, lists of books and reviews are `<ul>` lists, each review is an `<article>` with a `<time>` for its date, and actions are buttons or links. A `<div>` or `<span>` tells a screen reader nothing about what it contains, so we only use them where that is fine. A `<div>` groups elements for layout, and a `<span>` gives a part of a text its own styling, like the colored words in the heading on the home page, or holds text that is only meant for screen readers, like "Rated" and "out of 5" next to the stars.

- **Accessible components.** Our UI components are built on Base UI (through shadcn/ui), which handles keyboard navigation, focus and ARIA attributes for components like dialogs, comboboxes, selects and sliders. Buttons and inputs show a visible focus ring when they are reached with the keyboard. The shadcn components in `frontend/app/components/ui` are not changed or commented. Their `<div>` and `<span>` elements are wrappers around elements that already have the right role and behavior, so they do not make the components less accessible. By editing them and changing the HTML elements, we could easily break the accessibility behavior the primitives already provide.

- **Forms.** Every field has a label connected to its input, invalid fields are marked with `aria-invalid`, and help text (such as the minimum password length) is connected with `aria-describedby`. Error messages are shown with `role="alert"`, so screen readers read them out as they appear. We also set `autoComplete` on the fields, so browsers and password managers can fill them in, and the error messages tell the user what went wrong, for example that the email is already in use.

Expand Down
54 changes: 53 additions & 1 deletion docs/ai-documentation.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,58 @@ We have used Claude (through Claude Code) as a tool during development. In short

## How we keep humans in the loop

- **AI contributions are marked.** Where AI contributed directly to a piece of code, this is stated either in a comment in the code or in the commit message.
- **AI contributions are marked.** Where AI contributed directly to a piece of code, this is stated either in a comment in the code or in the pull request.
- **All AI-generated code is reviewed.** Every piece of AI-generated code has been reviewed by a team member, and in most cases rewritten or adjusted. We experienced that AI sometimes overdoes a task, so we simplify its suggestions to avoid over-engineering.
- **AI is a tool, not a replacement.** Our use of GitHub issues, pull requests and reviews of each other's work shows that there is always a human in the loop, and that AI supports our development work rather than replacing it.

## Learning and AI

There is a strong correlation between using AI and how much you learn and remember. There are multiple studies regarding this, with many reporting somewhat negative results when students (and people in general) are overly reliant on AI.

For example, [Walker, et al. (2026)](https://scale.stanford.edu/ai/evidence-base-review/evidence-base-ai-k12-november-review) reviewed the AI usage in K-12 education and reported that *"AI appears more likely to support learning when students use it to understand new material than when they use it to produce work for them, although neither type of use consistently improves learning."*

[Liu, et al. (2026)](https://arxiv.org/pdf/2604.04721) find that *"Across a variety of tasks, including mathematical reasoning and reading comprehension, we find that although AI assistance improves performance in the short-term, people perform significantly worse without AI and are more likely to give up."*

These studies make it clear that if AI shall be helpful for learning, it must be used correctly. Otherwise, it is likely to cause more harm than good.

Our team members have wildly different levels of expertise in web development, and this is something we understand and accept. Those team members who haven't done much web development before this project avoided AI either completely or a lot of the time. There is a lot of learning in performing the research needed, reading documentation, searching for questions on Google and other search engines, and experimenting with solutions that may not work ideally.

Furthermore, if used correctly, AI can be used to help explain concepts when you're truly stuck - however, there is a balance between using AI as a tutor, and as a fast solution. This is difficult to do in practice, so AI should be used very carefully by members who would like to learn as much as possible.

No matter whether the code was written manually or using help from LLMs, all issues and pull requests must have a proper description, as required by our [CONTRIBUTING.md](../CONTRIBUTING.md) file. This forces all group members to explain their thought process, reasoning for their code, and makes it obvious if someone does not understand the code at all. Fortunately, we have not had such issues in our group, and practically all pull requests have had coherent descriptions which are easy to understand.

## Code generated by AI is quality-checked in the same strict way as all other code

All code that LLMs (and humans) write should be checked by ESLint, Prettier and our Vitest tests and E2E tests before pushing to git.
Furthermore, we have checks in CI (GitHub Actions) which run all of these, excluding the E2E tests (see the [project choices and reasoning documentation](./choices-and-reasoning.md) for further details).
These checks confirm whether the code passes these strict requirements, and if it does not, it will not get merged. It's that simple.

Some things cannot be checked automatically, such as some of the practices described in our [CONTRIBUTING.md](../CONTRIBUTING.md) file, so after the automatic checks, we still perform human review on all pull requests. In order for a pull request to be merged, all conversations must be resolved, and it needs at least one explicit approving review.

## LLMs are unpredictable - and their access is restricted based on that

The LLMs used by our group do not have access to run any write operations using git. This means no automatic committing, pushing or otherwise adding code that has not been quality checked.
Furthermore, the LLMs only have access to the fewest tools they need to get the job done. That means reading and editing only the files they need, and performing only the terminal commands that are needed.
This is important to avoid situations where LLMs do something very stupid, such as modifying git history, deleting important files or otherwise attempting to "escape the box".
Using configuration files, Claude or other LLMs also do not have access to read `.env` or other files containing secrets which shall not be shared.

Last, but definitively not least:

> [!IMPORTANT]
> **No LLM shall ever have any access to our infrastructure, including our VM, deployed application, database or other systems** where real damage could be done by being careless.
> Automated deployment scripts, such as by using CI/CD via GitHub Actions, can be considered. However, no unpredictable and non-deterministic process may be used in a production environment.
## Examples of rejecting AI advice

While LLMs often have good ideas, they may not always fit what we're trying to achieve in the project, or they may not follow our code style or guidelines.

Some examples include:

- Claude suggested using an undocumented Goodreads API to load image covers of different sizes for books.
While this may be a good idea on paper, this API can change at any time, which would mean we have to rewrite our own code, or it could lead to unintended side effects.
This idea was rejected, and the decision is documented in our [sustainability documentation](./sustainability.md).
- LLMs sometimes weren't following our code style and guidelines. In order to document how we should write code and what checks need to run before one can commit new code to the project, we have added the [CONTRIBUTING.md](../CONTRIBUTING.md) file.
This file is mainly intended for human readers, but LLMs can also use it as input.
- An LLM attempted to use the `DROP TABLE books` SQL command when testing for SQL injection in our app.
This did not lead to any data loss, because the app wasn't vulnerable and the only database it had access to was the local development database, which does not contain any important data.
However, this prompted us to write extra guidelines regarding how the app is security-tested to avoid running potentially dangerous commands. These rules are saved locally for team members using AI like Claude.
28 changes: 25 additions & 3 deletions docs/choices-and-reasoning.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,30 @@ Search results are fetched 12 at a time with `limit` and `offset`, together with

We chose offset pagination based on how we expect the app to be used. Most users look at the first few pages of results, and change their search or filters if they don't find what they are looking for. The cost of `offset` only grows with how far out you go: to show page 600, the database has to step past all the rows on the pages before it. Since browsing that deep is very rare, we think page numbers are worth more to our users than what we would gain from keyset (cursor) pagination, which keeps every page equally fast but only lets you move to the next or previous page. The pagination in the interface shows the first and last page and the pages around the current one, so an arbitrary page can only be opened from the URL. With page numbers, the URL stays short and readable, and we can show which page you are on out of how many.

As the dataset grows, keeping the first pages fast depends on database indexes on the columns we sort and filter by (planned in #77), and the total count could be capped or estimated instead of counting every match.
Keeping the first pages fast depends on database indexes. We have added indexes on the columns we sort by (number of ratings, rating, title, pages and publish year), on the language and book format filters, and trigram indexes for the search on title and author (see `backend/src/db/schema/books.ts`). If the dataset grows much larger, the total count could be capped or estimated instead of counting every match.

## Books without ratings are stored as NULL

The dataset uses a rating of 0.0 for books nobody has rated. We store these as `NULL` instead, so they aren't treated as the worst-rated books, and they are placed last when sorting by rating.

## Sorting

The search results can be sorted by relevance (the default), rating, title, publish date and number of pages.

Relevance shows the books with the most ratings first, so well-known books come before books that few people have rated. When a search has no exact matches and we show books with similar titles or authors instead, the closest match comes first.

### Sorting by highest rating adds a minimum number of ratings

When the user chooses "Rating: high to low", we also add the filter "10,000+ ratings", unless the user has already chosen a minimum number of ratings. A toast tells the user that the filter was added, and that it can be changed in the filters.

Without a minimum, this sort order is not very useful. More than 800 books in our dataset have a rating of 5.0, and the one with the most ratings has only 36, so about the first 70 pages would be books that almost nobody has rated. A single 5-star review from one of our users on a book without ratings would also place it among them. With the minimum, about 12,600 of our roughly 52,000 books are left, and it is the same limit as we use for the top-rated books on the home page.

We discussed whether a filter that is chosen for the user is more annoying than useful (#117). We kept it because it is easy to notice and easy to remove: the toast explains it, the filter button shows how many filters are active, and the minimum can be set back to "Any". We also never replace a minimum that the user has chosen. The filter stays when the user switches to another sort order, since filters and sorting are independent everywhere else.

### No sorting by author

We do not offer sorting by author (#100). The author field in the dataset is free text and can hold several names, like "Author One, Author Two". We have no guarantee that the authors of a book are always listed in the same order, or whether a name is written as "First Last" or "Last, First", so sorting on this field would often give an order that looks random. Authors can be found with the search field instead, which searches both titles and authors.

## Selecting several genres shows books in any of them

When several genres are selected, we show books that belong to at least one of them (OR), not all of them (AND). This is because it widens the search instead of quickly ending up with no results.
Expand Down Expand Up @@ -90,11 +108,15 @@ These cover almost all of the browser engines that are in use, i.e. Chromium, Ge
We have skipped Microsoft Edge and (branded) Google Chrome because we already test Chromium, which is the browser engine these use.
Mobile Chrome and Mobile Safari are used to test the app on mobile screens.

We run the tests with one worker, so only one test runs at a time (`workers: 1` in `frontend/playwright.config.ts`).
With several workers, the tests run in several browsers at the same time against the same local backend, and we got timeouts and other failures that were not caused by bugs in the app.
How many workers a machine can handle differs, so one worker gives the same results for everyone on the team. The price is that a full run takes longer.

We do not use CI for E2E tests. Our VM only has 1 CPU core available and the tests take a very long time. They also slow down our app, which is running on the same server.
Instead, we use CI for other tasks, such as linting and formatting.

## Changes/not implemented yet from our specification

- **Filters:** We filter on genres, language, book format and number of pages. The specification also mentioned author, publisher, place and person, which we have not implemented yet.
- **Filters:** We filter on genres, language, book format, number of pages and a minimum number of ratings. The specification also mentioned author, publisher, place and person. Authors are covered by the search field, which searches both titles and authors, and we have not implemented filters for publisher, place and person.
- **Login:** Instead of Google login, we support email/password and GitHub and Discord login. Google was rejected since it required https connection, which we do not provide.
- **Reviews:** Reviews with a star rating are planned for the next delivery.
- **Reviews:** Implemented in delivery 4 as specified, with a star rating from 1 to 5 and an optional text. Reviews are written and shown on the book's page, and the user's own reviews are also listed on their profile. A book's rating combines the rating from the dataset with the reviews from our users.
Loading