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
4 changes: 2 additions & 2 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ All GitHub issues:
- We want to state explicitly that issues MUST NOT be empty, i.e., have no description
- MUST have a fitting type ("Bug", "Feature" or "Task")
- MUST be connected to a milestone, if a fitting one is available. Otherwise, this is OPTIONAL
- MUST be assigned to the person(s) working on the issue as soon as you being work
- MUST be assigned to the person(s) working on the issue as soon as you begin work
- This helps us avoid duplicate work being done
- MUST be connected to a pull request as soon as a PR that will resolve this issue is opened
- SHOULD have a fitting label, but it MAY be skipped in some rare cases
Expand Down Expand Up @@ -292,7 +292,7 @@ cd frontend
pnpm e2e
```

They need the local database to be running with the book dataset, see the [frontend README](./frontend/README.md#playwright-end-to-end-tests).
They need the local database to be running with the book dataset, see the [frontend README](./frontend/README.md#playwright-e2e-tests).

### Creating a pull request

Expand Down
8 changes: 4 additions & 4 deletions backend/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
- [Install PostgreSQL](#install-postgresql)
- [Linux](#linux)
- [Windows](#windows)
- [MacOS](#macos)
- [macOS](#macos)
- [Set the environment variables](#set-the-environment-variables)
- [Download the dataset](#download-the-dataset)
- [Set up the database](#set-up-the-database)
Expand Down Expand Up @@ -51,9 +51,9 @@ Otherwise, Postgres and its utilities need to be added to your `PATH`.
If you need help, you can use [this guide](https://www.architectryan.com/2018/03/17/add-to-the-path-on-windows-10/).
The most likely path that you need to add is `C:\Program Files\PostgreSQL\18\bin`, however, if you chose a different installation folder, you need to adjust this path.

#### MacOS
#### macOS

The simplest way to install Postgres on MacOS is to use [homebrew](https://brew.sh/):
The simplest way to install Postgres on macOS is to use [homebrew](https://brew.sh/):

```sh
brew install postgresql@18
Expand All @@ -68,7 +68,7 @@ cd backend
cp .env.example .env
```

The `.env` file will be your own, gitignored version.
The `.env` file will be your own, gitignored version. Make sure to set the `BETTER_AUTH_SECRET` value, and provide secrets for the GitHub and Discord login if you'd like to use them.

Proceed to do the following:

Expand Down
29 changes: 15 additions & 14 deletions docs/accessibility.md

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions docs/ai-documentation.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Use of AI in this project <!-- omit from toc -->
# Use of AI in this project <!-- omit in toc -->

- [Overview](#overview)
- [How we keep humans in the loop](#how-we-keep-humans-in-the-loop)
Expand Down Expand Up @@ -28,7 +28,7 @@ We have used Claude (through Claude Code) as a tool during development. In short

- **[AGENTS.md](../AGENTS.md)**: the instructions every AI agent gets. It is short on purpose. It contains the rules from this document, a short overview of the project, a definition of done, and a table that says which documentation to read before which kind of change. It points to [CONTRIBUTING.md](../CONTRIBUTING.md), the READMEs and the files in `docs/` instead of repeating them, so each rule is written in one place.
- **[CLAUDE.md](../CLAUDE.md)**: Claude Code reads this file and not `AGENTS.md`, so it imports `AGENTS.md` and `CONTRIBUTING.md`, which loads both in every session, and adds the few things that only apply to Claude Code. Other tools, such as Cursor and Codex, read `AGENTS.md` directly.
- **[.claude/settings.json](../.claude/settings.json)**: turns the restrictions described [below](#llms-are-unpredictable---and-their-access-is-restricted-based-on-that) into configuration that is the same for all of us. Claude Code is denied reading `.env` files, running git commands that write, and using `ssh`. It has to ask before commands that delete or change the local database, and may run lint, typecheck, tests and build without asking.
- **[.claude/settings.json](../.claude/settings.json)**: turns the restrictions described [below](#llm-restrictions) into configuration that is the same for all of us. Claude Code is denied reading `.env` files, running git commands that write, and using `ssh`. It has to ask before commands that delete or change the local database, and may run lint, typecheck, tests and build without asking.
- **Skills** in [.claude/skills](../.claude/skills/): written-down procedures for work we do again and again, which the agent loads when they are needed:
- `pre-pr-check` runs the pull request checklist from CONTRIBUTING.md and reports what passed and what was not verified.
- `docs-check` compares a change with our documentation in both directions: that the code follows the documentation, and that the documentation still describes the code.
Expand Down Expand Up @@ -69,7 +69,7 @@ Furthermore, the LLMs only have access to the fewest tools they need to get the
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. For Claude Code, these restrictions are in the shared [.claude/settings.json](../.claude/settings.json).

Last, but definitively not least:
Last, but definitely 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.
Expand Down
6 changes: 3 additions & 3 deletions docs/deployment.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ nano .profile
source .profile
```

This will ensure that the PostgreSQL binaries and binaries installed with pnpm (like pm2) are added to PATH.
This will ensure that the PostgreSQL binaries are added to PATH.

## Set up the project

Expand Down Expand Up @@ -153,11 +153,11 @@ pnpm db:migrate

## Run the project

The frontend is already handling by the Apache web server by being placed in `/var/www/html/project2`.
The frontend is already handled by the Apache web server by being placed in `/var/www/html/project2`.

In order to run the backend, we use `pm2`.

The first time project is run:
The first time the project is run:

```sh
cd backend
Expand Down
5 changes: 2 additions & 3 deletions docs/infrastructure.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ flowchart TB
subgraph external["External services"]
oauth["GitHub and Discord"]
covers["Goodreads image servers"]
fonts["Google Fonts"]
end
browser -- "HTML, JS and CSS" --> apache
Expand All @@ -37,13 +36,13 @@ flowchart TB
auth -- "exchange OAuth code" --> oauth
browser -- "OAuth login" --> oauth
browser -- "cover images" --> covers
browser -- "font files" --> fonts
```

- **Apache** only serves the built frontend files. React Router runs in the browser, since we don't use server-side rendering, and `FallbackResource` makes Apache return `index.html` for routes like `/project2/book/5`.
- **The backend** runs in pm2 on port 3001. The same Express server handles GraphQL requests at `/` and authentication at `/api/auth`, and only accepts requests from the frontend's address (CORS).
- **PostgreSQL** runs from the project folder (`backend/db-data`) and only listens on `127.0.0.1`, so it can't be reached from outside the VM.
- **Cover images and fonts** are loaded by the browser directly from Goodreads and Google Fonts, not through our VM.
- **Cover images** are loaded by the browser directly from Goodreads, not through our VM.
- **Fonts** are self-hosted and loaded directly using the `@fontsource-variable/inter` package.

## Common technologies

Expand Down
19 changes: 10 additions & 9 deletions docs/sustainability.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,16 @@

## Limitations and future work

This section is meant as an overview of potential improvements with regard to sustainability, and also shows that we are aware of the downsides of our implementation. The table has a column for the status at delivery 3, and the same table will be used to show what work has been done from delivery 3 to 4. More items can be added after delivery 3, and will be written inside the same table, with "Added after delivery 3" mark.

| Limitation | Possible improvement | Delivery 3 | Delivery 4 |
| ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ---------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Cover images are loaded when the page renders, also those outside the screen, and have no fixed width or height. | Add `loading="lazy"` and set `width`/`height` on the `<img>` in `BookCover.tsx`, so off-screen images load only when needed and the layout doesn't shift. | Not done | Done. Covers use `loading="lazy"`, except on the book page where the cover is visible right away. The cover box already has a fixed aspect ratio, so no `width`/`height` is needed to avoid layout shift. |
| We use the cover URLs from the dataset as they are, which may be larger images than the size we display them at. | Measure the image sizes, and use a smaller image variant if the image host offers one. | Not done | Won't do. Different covers are available from Goodreads through guesses regarding the correct URL, but the API is undocumented and may change at any time. This means our code loading images could stop working at any time, so we prefer to use URLs we know are working correctly. |
| The app loads two font families: Inter (self-hosted with `@fontsource`) and Open Sans (from Google Fonts). | Use one font family and host it ourselves, which removes an external request and one set of font files. | Not done | Done. Open Sans was not used anywhere, so we removed it. |
| Apollo caches the lists of genres, languages and formats in each browser, but the backend computes them again with a `GROUP BY` over the whole `books` table every time a browser without them asks. | Cache the lists in the backend, so they are computed once and shared between all users. They only change when the dataset changes. | Not done | Done. The backend computes each list once and keeps it in memory until the server restarts. The server must also be restarted if we ever change the book dataset. |
| Added after delivery 3: Apache sent our own JS, CSS and font files without cache headers, so browsers asked for them again on every visit. | Let browsers keep the files in `assets/` for a year, since their names change whenever their content changes. See the [deployment documentation](./deployment.md#apache-config). | - | Done |
This section is meant as an overview of potential improvements with regard to sustainability that we discovered during the app development.
The table has a column for the status at delivery 3 and 4, and it shows what work has been done. Items added after delivery 3 are marked with the "Added after delivery 3" comment.

| Limitation | Possible improvement | Delivery 3 | Delivery 4 |
| ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Cover images are loaded when the page renders, also those outside the screen, and have no fixed width or height. | Add `loading="lazy"` and set `width`/`height` on the `<img>` in `BookCover.tsx`, so off-screen images load only when needed and the layout doesn't shift. | Not done | Done. Covers use `loading="lazy"`, except on the book page where the cover is visible right away. The cover box already has a fixed aspect ratio, so no `width`/`height` is needed to avoid layout shift. |
| We use the cover URLs from the dataset as they are, which may be larger images than the size we display them at. | Measure the image sizes, and use a smaller image variant if the image host offers one. | Not done | Won't do. Different covers are available from Goodreads through guesses regarding the correct URL, but the API is undocumented and may change at any time. This means our code loading images could stop working at any time, so we prefer to use URLs we know are working correctly. |
| The app loads two font families: Inter (self-hosted with `@fontsource`) and Open Sans (from Google Fonts). | Use one font family and host it ourselves, which removes an external request and one set of font files. | Not done | Done. Open Sans was not used anywhere, so we removed it. |
| Apollo caches the lists of genres, languages and formats in each browser, but the backend computes them again with a `GROUP BY` over the whole `books` table every time a browser without them asks. | Cache the lists in the backend, so they are computed once and shared between all users. They only change when the dataset changes. | Not done | Done. The backend computes each list once and keeps it in memory until the server restarts. The server must also be restarted if we ever change the book dataset. |
| Added after delivery 3: Apache sent our own JS, CSS and font files without cache headers, so browsers asked for them again on every visit. | Let browsers keep the files in `assets/` for a year, since their names change whenever their content changes. See the [deployment documentation](./deployment.md#set-up-apache-config). | - | Done |

## Lighthouse

Expand Down